﻿/*
* InfoJetSoft Copyright 2005-2012
* Updated 2012.11.02
*/
var InfoJet_WebContext = "";
var InfoJet_NoErrorFormatting = false;
var InfoJet_BrowserQuick = false;
var InfoJet_Changed = false;
var InfoJet_Postbacking = 0;
var InfoJet_ValidSubmit = true;
//CID 0641 //2010.11.06 //Begin
var InfoJet_LocalResources = {};
//CID 0474 //2009.12.23 //Begin
InfoJet_LocalResources["ClickAgainMessage"] = "The button click is interrupted by a postback, please try again.";
//CID 0474 //2009.12.23 //End
InfoJet_LocalResources["CorrectFirstMessage"] = "This form contains validation errors. Errors are marked with either a red asterisk(required fields) or a red, dashed border(invalid values). \nPlease correct them first.";
InfoJet_LocalResources["TryAgainMessage"] = "Please try again while the postback progress is finished.";
InfoJet_LocalResources["CloseAnywayMessage"] = "The document has been changed, do you want to close anyway?";
InfoJet_LocalResources["DeleteAllMessage"] = "This action will delete all information in the current form.\n\nDo you want to continue?";
//CID 0641 //2010.11.06 //End
var InfoJet_AMP = "&";
var InfoJet_NoValidation = false;
var InfoJet_NoPostback = false;
//CID 0134 //2008.10.05 //Begin
//CID 0291 //2009.05.31 //Begin
var InfoJet_UseAjax = true;
//CID 0291 //2009.05.31 //End
//CID 0134 //2008.10.05 //End
var InfoJet_XHR = null;
var InfoJet_AjaxBracket = null;  //for EditPart.
var InfoJet_ShortDatePattern = "yyyy-M-d";
var InfoJet_LongDatePattern = "yyyy-MM-dd";
var InfoJet_YearMonthPattern = "yyyy-M";
var InfoJet_XdPrefix = "xd:";
var InfoJet_SelectFileMessage = "[Please select a file ...]";
var InfoJet_EnableUnderline = false;
var InfoJet_XDocumentDOM = null;
//CID 1554 //2012.12.24 //Begin
var InfoJet_ReplaceBrowserContextMenu = false;
//CID 1554 //2012.12.24 //End
var InfoJet_ShowMenuArrow = true;
var InfoJet_Progress = null;
var InfoJet_ShowProgress = false;
var InfoJet_ItemElement = null;
//CID 0077 //2008.08.03 //Begin
//CID 0255 //2009.05.23 //Begin
var InfoJet_Canvas = null;
var InfoJet_IsCanvasTranparent = true;
//CID 0255 //2009.05.23 //End
//CID 0380 //2009.09.22 //Begin
var InfoJet_FocusHolder = null;
//CID 0380 //2009.09.22 //End
//CID 0077 //2008.08.03 //End
var InfoJet_FuncAfterInit = null;
//CID 0023 //2008.06.19 //Begin
var InfoJet_SaveAsPage = null;
//CID 0023 //2008.06.19 //End
//CID 0048 //2008.07.15 //Begin
var InfoJet_EnableReplaceGroupingSymbol = false;
//CID 0048 //2008.07.15 //End
//CID 0262 //2009.03.26 //Begin
var InfoJet_ViewSwitchValidation = false;
//CID 0262 //2009.03.26 //End
//CID 0009 //2008.06.03 //Begin
var InfoJet_SaveAsWindow = null;
//CID 0009 //2008.06.03 //End
var InfoJet_Selects = null;
//CID 0286 //2009.05.11 //Begin
var InfoJet_XmlToEditItems = null;
//CID 0286 //2009.05.11 //End
//CID 0255 //2009.03.22 //Begin
var InfoJet_FocusControlId = null;
//CID 0255 //2009.03.22 //End
//CID 0296 //2009.06.23 //Begin
var InfoJet_NewStructureNodeId = null;
//CID 0296 //2009.06.23 //End
//CID 0332 //2009.08.07 //Begin
var InfoJet_OldValueState = null;
//CID 0332 //2009.08.07 //End
//CID 0407 //2009.09.27 //Begin
var InfoJet_HookDocumentOnClickEvent = true;
//CID 0407 //2009.09.27 //End
//CID 0400 //2009.11.24 //Begin
var InfoJet_FocusFirstControlAfterInited = false;
//CID 0400 //2009.11.24 //End
//CID 0471 //2009.11.30 //Begin
var InfoJet_NumberDecimalSeparator = ".";
var InfoJet_NumberGroupSeparator = ",";
var InfoJet_CurrencyDecimalSeparator = ".";
var InfoJet_CurrencyGroupSeparator = ",";
//CID 0471 //2009.11.30 //End
//CID 0400 //2009.12.09 //Begin
var InfoJet_ScrollFollowUpFormViewIntoView = false;
//CID 0400 //2009.12.09 //End
//CID 0474 //2009.12.23 //Begin
var InfoJet_CachedPostbackButtonId = null;
//CID 0474 //2009.12.23 //End
//CID 0492 //2010.02.04 //Begin
var InfoJet_Container = null;
var InfoJet_OffsetX = 0;
var InfoJet_OffsetY = 0;
//CID 0492 //2010.02.04 //End
//CID 0499 //2010.03.17 //Begin
var InfoJet_CurrentDialog = null;
//CID 0499 //2010.03.17 //End
//CID 0526 //2010.03.30 //Begin
var InfoJet_NonProofingNodeNameArrays = null;
//CID 0526 //2010.03.30 //End
//CID 0526 //2010.03.31 //Begin
var InfoJet_CurrentViewName = null;
//CID 0526 //2010.03.31 //End
//CID 0544 //2010.05.12 //Begin
var InfoJet_HideTryAgainNotification = false;
//CID 0544 //2010.05.12 //End
//CID 0500 //2010.07.29 //Begin
var InfoJet_PSVITable = null;
//CID 0500 //2010.07.29 //End
//CID 0629 //2010.07.30 //Begin
var InfoJet_OnChangeTable = null;
//CID 0629 //2010.07.30 //End
//CID 0673 //2010.09.29 //Begin
var InfoJet_FieldOverTop = null;
var InfoJet_FieldOverBottom = null;
var InfoJet_FieldOverLeft = null;
var InfoJet_FieldOverRight = null;
var InfoJet_ItemOverTop = null;
var InfoJet_ItemOverBottom = null;
var InfoJet_ItemOverLeft = null;
var InfoJet_ItemOverRight = null;
var InfoJet_FieldFocusTop = null;
var InfoJet_FieldFocusBottom = null;
var InfoJet_FieldFocusLeft = null;
var InfoJet_FieldFocusRight = null;
var InfoJet_ItemFocusTop = null;
var InfoJet_ItemFocusBottom = null;
var InfoJet_ItemFocusLeft = null;
var InfoJet_ItemFocusRight = null;
//CID 0673 //2010.09.29 //End
//CID 0670 //2010.10.04 //Begin
var InfoJet_FormatReadonlyView = false;
//CID 0785 //2011.02.22 //End
//CID 0664 //2010.10.07 //Begin
var InfoJet_EnableFormFieldsCache = false;
//CID 0664 //2010.10.07 //End
//CID 0735 //2010.12.23 //Begin
var InfoJet_OnClickTable = null;
//CID 0735 //2010.12.23 //End
//CID 0828 //2011.03.10 //Begin
var InfoJet_FocusItemIndex = -1;
//CID 0828 //2011.03.10 //End
//0880 //2011.04.22 //Begin
var InfoJet_PingXHR = null;
var InfoJet_PingInterval = 60 * 1000 * 5;
var InfoJet_PingParameter = null;
var InfoJet_IsPinging = false;
//0880 //2011.04.27 //End
//CID 1147 //2012.03.28 //Begin
var InfoJet_RedAsteriskOTA = false;
//CID 1147 //2012.03.28 //End
//CID 1320 //2012.09.12 //Begin
var InfoJet_RtbPanel = null;
//CID 1320 //2012.09.12 //End
//CID 1336 //2012.09.17 //Begin
var InfoJet_NicEditor = null;
//CID 1336 //2012.09.17 //End
//CID 1366 //2012.10.04 //Begin
var InfoJet_EditRichTextOnFocus = false;
//CID 1366 //2012.10.04 //End
//CID 1376 //2012.10.09 //Begin
var InfoJet_NicEditor_PaneExisting = false;
//CID 1376 //2012.10.09 //End
//CID 1422 //2012.10.31 //Begin
var InfoJet_EnablePlaceholderUI = false;
//CID 1422 //2012.10.31 //End

//CID 0781 //2011.02.06 //Begin
function InfoJet_Log(message) {
    var logTextArea = document.getElementById("InfoJet_LogTextArea");
    if (logTextArea != null) {
        logTextArea.value += "\r\n" + message;
    }
}
//CID 0781 //2011.02.06 //End

//CID 1548 //2013.01.09 //Begin
function InfoBus_GetIFrameContext() {
    if (parent) {
        if (typeof (parent.InfoBus_CustomGetIFrameContext) != "undefined") {
            return parent.InfoBus_CustomGetIFrameContext();
        }
    }
    return null;
}
//CID 1548 //2013.01.09 //End

//CID 0844 //2011.03.24 //Begin
function InfoJet_ResolveServiceAction() {
    var lastIndex = window.location.pathname.lastIndexOf("/");
    var path = window.location.pathname.substring(0, lastIndex + 1);
    var action = document.getElementById("xdoc_param_action").value;
    var isRelativeAction = true;
    if(/^[A-Za-z]:\\/.test(action)){
        isRelativeAction = false;
    }
    if (action.indexOf("\\") == 0) {
        isRelativeAction = false;
    }
    if (action.indexOf("/") == 0) {
        isRelativeAction = false;
    }
    if (isRelativeAction) {
        var serviceAction = path + action;
        return serviceAction;
    } else {
        return action;
    }
}
//CID 0844 //2011.03.24 //End

function InfoJet_IsValid(){
	var xdocError = document.getElementById( "xdoc_data_error" );
	if( xdocError == null ){
		return true;
	}
	//CID 0278 //2009.05.02 //Begin
	var errorCount = 0;
	for( var i = 0; i < xdocError.childNodes.length; i ++ ){
		if( xdocError.childNodes[ i ].nodeType == 1 ){
			errorCount ++;
		}
	}
	//CID 0278 //2009.05.02 //End
	if( errorCount > 0 ){
		return false;
	}else{
		return true;
	}
	return true;
}

function InfoJet_IsViewValid(){
	var xdocFieldStyles = document.getElementById( "xdoc_fieldstyle" );
	if( xdocFieldStyles == null ){
		return true;
	}
	//CID 0278 //2009.05.02 //childNodes
	for( var i = 0; i < xdocFieldStyles.childNodes.length; i ++ ){
		var fieldStyle = xdocFieldStyles.childNodes[ i ];
		if( fieldStyle.nodeType == 1 ){
			if( fieldStyle.id.lastIndexOf( "_notBlank" ) == (fieldStyle.id.length - 9) ){
				if( fieldStyle.style.display != "none" ){
					return false;
				}
			}else{
				if( parseInt(fieldStyle.style.height) > 0 || parseInt(fieldStyle.style.width) > 0 ){
					return false;
				}
			}
		}
	}
	return true;
}

function InfoJet_NeedSectionBorder( section ){
	if( section == null ){
		return;
	}
	if( section.tagName ){
		var tagName = section.tagName.toLowerCase();
		try{
		    var xctname = section.getAttribute(InfoJet_XdPrefix + "xctname");
			if( xctname == null || xctname.length <= 0 ){
				if( tagName == "tr" || tagName == "td" ){
					return true;
				}else{
					return false;
				}
			}else if( xctname != null && xctname == "ExpressionBox"  ){
				return false;
			}else{
				return true;
			}
		}catch( e ){
			return false;
		}
	}
}

function InfoJet_NeedFieldBorder( control ){
	if( InfoJet_IsTextControl( control ) ){
		if( !control.disabled ){
			return true;
		}else{
			return false;
		}
	}
	var tagName = control.tagName.toLowerCase();
	if( tagName == "img" ){
		return true;
	}
	return false;
}

function InfoJet_IsTextControl( control ){
    //CID 0829 //2011.03.08 //Begin
    var isTextControl = control.getAttribute("isTextControl");
    if (isTextControl == null) {
        isTextControl = InfoJet_CheckTextControl(control);
        control.setAttribute("isTextControl", isTextControl);
    }
    if (isTextControl == "1") {
        return true;
    } else {
        return false;
    }
    //CID 0829 //2011.03.08 //End
}

//CID 0829 //2011.03.08 //Begin
function InfoJet_CheckTextControl(control) {
    //CID 0408 //2009.09.29 //Begin
    var tagName = null;
    try {
        tagName = control.tagName.toLowerCase();
    } catch (e) {
        return "0";
    }
    //CID 0408 //2009.09.29 //End
    if (tagName == "input") {
        var type = control.getAttribute("type");
        if (type != null) {
            type = type.toLowerCase();
            if (type == "text" || type == "password") {
                return "1";
            }
        }
    } else if (tagName == "textarea") {
        return "1";
    }
    return "0";
}
//CID 0829 //2011.03.08 //End

//CID 0477 //2009.12.18 //Begin
function InfoJet_IsSingleLineTextControl( control ){
	if( InfoJet_IsTextControl( control ) ){
		var tagName = null;
		try{
			tagName = control.tagName.toLowerCase();
		}catch(e){
			return false;
		}
		if( tagName == "input" ){
			return true;
		}
		if( tagName == "textarea" ){
			if( InfoJet_IsIdInArray( InfoJet_GetElementId( control ) , "xdoc_data_nobreak_id_array" ) ){
				return true;
			}
			var defaultRows = control.getAttribute( "default_rows" );
			if( defaultRows != null && defaultRows == "1" ){
				return true;
			}
		}
	}
	return false;
}
//CID 0477 //2009.12.18 //End

function InfoJet_IsSelect( control ){
	var tagName = control.tagName.toLowerCase();
	if( tagName == "select" ){
		return true;
	}
	return false;
}

function InfoJet_IsIdInArray( id , idArrayName ){
	var element = document.getElementById( idArrayName );
	if( element == null ){
		return false;
	}
	var idArray = element.innerHTML;
	var ids = idArray.split( ";" );
	for( var i = 0 ; i < ids.length ; i ++ ){
		if( id == ids[ i ] ){
			return true;
		}
	}
	return false;
}

function InfoJet_GetElementId( element ){
	var id = element.id;
	return InfoJet_GetPureId( id );
}

function InfoJet_GetPureId( id ){
	var index = id.indexOf( "," );
	if( index > 0 ){
		return id.substr( 0 , index );
	}else{
		return id;
	}
}

function InfoJet_PureIdEquals( id1, id2 ){
	if( InfoJet_GetPureId( id1 ) == InfoJet_GetPureId( id2 ) ){
		return true;
	}else{
		return false;
	}
}

function InfoJet_IsIE(){
	if( document.all ){
		return true;
	}else{
		return false;
	}
}

//CID 0515 //2010.03.24 //Begin
function InfoJet_IsIE7(){
	if (typeof(document.body.style.maxHeight) != "undefined"){
		return true;
	}else{
		return false;
	}
}
//CID 0515 //2010.03.24 //End

function InfoJet_GetEvent( event ){
	if( event == null ){
		return window.event;
	}else{
		return event;
	}
}

function InfoJet_GetParent( element ){
	if( element == null ){
		return null;
	}
	if( InfoJet_IsIE() ){
		return element.parentElement;
	}else{
		return element.parentNode;
	}
}

//CID 0278 //2009.05.02 //Begin
function InfoJet_GetAllChildren( element ){
	var all = new Array();
	InfoJet_GetChildren( element , all );
	return all;
}
//CID 0278 //2009.05.02 //End

//CID 0278 //2009.05.02 //Begin
function InfoJet_GetChildren( element , all ){
	for( var i = 0; i < element.childNodes.length; i ++ ){
		var childNode = element.childNodes[ i ];
		if( childNode.nodeType == 1 ){
			all.push( childNode );
			InfoJet_GetChildren( childNode , all );
		}
	}
}
//CID 0278 //2009.05.02 //End

function InfoJet_GetFrameDocument( frameId ){
	if( InfoJet_IsIE() ){
		var frame = document.frames[ frameId ];
		return frame.document;
	}else{
		var frame = document.getElementById( frameId );
		return frame.contentDocument;
	}
}

function InfoJet_GetDocumentForm( document , formId ){
	if( InfoJet_IsIE() ){
		return document.forms[ formId ];
	}else{
		return document.getElementById( formId );
	}
}

function InfoJet_ShouldContinueBlur(){
	if( InfoJet_IsIE() ){
		var activeElement = document.activeElement;
		if( activeElement != null ){
			if( activeElement.id == "xdoc_menu_focus_arrow" ){
				return false;
            }
            //CID 1366 //2012.10.04 //Begin
            if(!InfoJet_EditRichTextOnFocus){
	            //CID 1101 //2012.05.24 //Begin
                if (activeElement.id == "xdoc_menu_rtb_edit") {
                    return false;
                }
                //CID 1101 //2012.05.24 //End
            }
            //CID 1366 //2012.10.04 //End
            var xdoc_menu = activeElement.getAttribute( "xdoc_menu" );
            if( xdoc_menu != null && xdoc_menu == "yes" ){
                return false;
                }
            }
            return true;
	}else{
		var menuArrow = document.getElementById( "xdoc_menu_focus_arrow" );
		//CID 0398 //2009.09.04 //menuArrow
		if( menuArrow && menuArrow.style.display == "block" ){
			return false;
        }
        //CID 1366 //2012.10.04 //Begin
        if(!InfoJet_EditRichTextOnFocus){
            //CID 1101 //2012.05.24 //Begin
            var rtbMenu = document.getElementById("xdoc_menu_rtb_edit");
            if (rtbMenu && rtbMenu.style.display == "block") {
                return false;
            }
            //CID 1101 //2012.05.24 //End
        }
        //CID 1366 //2012.10.04 //End
		return true;
	}
}

function InfoJet_SimulateFocus( event , source , type ){
	if( !InfoJet_IsIE() ){
		InfoJet_OnFocus( event , source , type );
	}
}

function InfoJet_GetPos( element ){
	try{
		var pos = {left:0 , top:0};
		if( InfoJet_IsIE() ){
			var rect = element.getBoundingClientRect();
			var offsetX = 0;
			var offsetY = 0;
			var first = element.getClientRects()[0];
			if( first.left == rect.left  ){
				offsetX = -2;
			}else{
				if( rect.left - first.left == -2 ){
					offsetX = 0;
				}else{
					try{
						var frame = element.ownerDocument.parentWindow.frameElement;
						if( frame ){
							var frameBorder = frame.frameBorder.toLowerCase();
							if( frameBorder == "" ){
								if( frame.parentElement.tagName.toLowerCase() == "frameset" ){
									var parentFrameBorder = frame.parentElement.frameBorder.toLowerCase();
									if( parentFrameBorder == "" ){
										offsetX = -2;
									}else if( ( parentFrameBorder == "1" || parentFrameBorder == "yes" ) && frame.parentElement.border == "" ){
										offsetX = -2;
									}else{
										offsetX = 0;
									}
								}else{
									offsetX = -2;
								}
							}else if( frameBorder == "1" || frameBorder == "yes" ){
								offsetX = -2;
							}else if( frameBorder == "0" || frameBorder == "no" ){
								offsetX = 0;
							}else{
								offsetX = -2;
							}
						}else{
							offsetX = -2;
						}
					}catch( e ){
						offsetX = -2;
					}
				}
			}
			if( first.top == rect.top  ){
				offsetY = -2;
			}else{
				if( rect.top - first.top == -2 ){
					offsetY = 0;
				}else{
					try{
						var frame = element.ownerDocument.parentWindow.frameElement;
						if( frame ){
							var frameBorder = frame.frameBorder.toLowerCase();
							if( frameBorder == "" ){
								if( frame.parentElement.tagName.toLowerCase() == "frameset" ){
									var parentFrameBorder = frame.parentElement.frameBorder.toLowerCase();
									if( parentFrameBorder == "" ){
										offsetY = -2;
									}else if( ( parentFrameBorder == "1" || parentFrameBorder == "yes" ) && frame.parentElement.border == "" ){
										offsetY = -2;
									}else{
										offsetY = 0;
									}
								}else{
									offsetY = -2;
								}
							}else if( frameBorder == "1" || frameBorder == "yes" ){
								offsetY = -2;
							}else if( frameBorder == "0" || frameBorder == "no" ){
								offsetY = 0;
							}else{
								offsetY = -2;
							}
						}else{
							offsetY = -2;
						}
					}catch( e ){
						offsetY = -2;
					}
				}
			}
			if( typeof window.dialogArguments != "undefined" ){
				offsetX = offsetX + 2;
				offsetY = offsetY + 2;
			}
			pos.left = rect.left + offsetX + document.body.scrollLeft + document.documentElement.scrollLeft;
			pos.top = rect.top + offsetY + document.body.scrollTop + document.documentElement.scrollTop;
		}else{
		    InfoJet_GetPosByOffset(element, pos);
		}
		//CID 0492 //2010.02.04 //Begin
		pos.left = pos.left - InfoJet_OffsetX;
		pos.top = pos.top - InfoJet_OffsetY;
		//CID 0492 //2010.02.04 //End
		return pos;
	}catch(exception){
		//CID 0501 //2010.01.23 //null
		return null;
	}
	return null;
}

function InfoJet_GetPosByOffset(element, pos) {
    //CID 0885 //2011.04.30 //Begin
    var rect = null;
    try {
        rect = element.getBoundingClientRect();
    } catch (e) { }
    if (rect != null) {
        var doc = element.ownerDocument;
        var documentElement = doc.documentElement;

        var body = doc.body;
        var clientLeft = documentElement.clientLeft || body.clientLeft || 0;
        var clientTop = documentElement.clientTop || body.clientTop || 0;
        var scrollLeft = window.pageXOffset || documentElement.scrollLeft || body.scrollLeft;
        var scrollTop = window.pageYOffset || documentElement.scrollTop || body.scrollTop;
        var left = rect.left + scrollLeft - clientLeft;
        var top = rect.top + scrollTop - clientTop;

        pos.left = left;
        pos.top = top;
    }
	//CID 0885 //2011.04.30 //End
}

function InfoJet_GetMarginBottom( element ){
	if( InfoJet_IsIE() ){
		return InfoJet_GetPixelSize( element.currentStyle.marginBottom );
	}else{
		var css = window.getComputedStyle( element , "" );
		return parseInt( css.getPropertyValue( "margin-bottom" ) );
	}
}

function InfoJet_GetStylePixelSize( element , ieProp , nsProp ){
	if( InfoJet_IsIE() ){
		var value = eval( "element.currentStyle." + ieProp );
		return InfoJet_GetPixelSize( value );
	}else{
		var css = window.getComputedStyle( element , "" );
		return parseInt( css.getPropertyValue( nsProp ) );
	}
}

function InfoJet_GetPixelSize( size ){
	if( size.indexOf( "pt" ) > 0 ){
		if( isNaN( parseInt( size ) ) ){
			return 0;
		}else{
			return parseInt( size ) * 2;
		}
	}else{
		if( isNaN( parseInt( size ) ) ){
			return 0;
		}else{
			return parseInt( size );
		}
	}
}

function InfoJet_GetBodyClientLeft(){
	if( document.body.clientLeft ){
		return document.body.clientLeft + 2;
	}else{
		return 2 + 2;
	}
}

function InfoJet_GetBodyClientTop(){
	if( document.body.clientTop ){
		return document.body.clientTop + 5;
	}else{
		return 2 + 5;
	}
}

//CID 0664 //2010.11.01 //Begin
function InfoJet_CreateField( fieldId ) {
    var xdocForm = document.getElementById("xdoc_form");
    var fieldHtml = '<input type=hidden id=' + fieldId + ' name=' + fieldId + ' value=>';
    InfoJet_InsertAdjacentHTMLBeforeEnd(xdocForm, fieldHtml);
    var xmlField = document.getElementById(fieldId);
    return xmlField;
}
//CID 0664 //2010.11.01 //End

//CID 0664 //2010.11.18 //Begin
function InfoJet_GetWriteOnlyField(fieldId) {
    var xmlField = document.getElementById(fieldId);
    //CID 0230 //2009.02.25 //Begin
    if (xmlField == null) {
        var toCreate = false;
        if (InfoJet_EnableFormFieldsCache) {
            toCreate = true;
        } else {
            if (fieldId.indexOf("xdoc_s_") == 0) {
                toCreate = true;
            }
        }
        if (toCreate) {
            xmlField = InfoJet_CreateField(fieldId);
        }
    }
    return xmlField;
    //CID 0230 //2009.02.25 //End
}
//CID 0664 //2010.11.18 //End

function InfoJet_UpdateField( control ){
	InfoJet_Changed = true;
	var fieldId = "xdoc" + InfoJet_GetElementId(control);
	//CID 0664 //2010.11.18 //Begin
	var xmlField = InfoJet_GetWriteOnlyField(fieldId);
	//CID 0664 //2010.11.18 //End
	//TODO.
	//CID 0213 //2009.01.22 //Begin
	document.getElementById("xdoc_param_old_value").value = xmlField.value;
	//CID 0213 //2009.01.22 //End
	var tagName = control.tagName.toLowerCase();
	if( tagName == "select" ){
		//CID 0382 //2009.09.22 //Begin
		xmlField.value = InfoJet_GetHtmlSelectValue( control );
		//CID 0382 //2009.09.22 //End
	}else if( tagName == "img" ){
		xmlField.value = control.src;
	}else if( tagName == "input" ){
		var type = control.type.toLowerCase();
		if( type == "text" || type == "password" ){
			//Check xml_value first, xml_value is used for the formatting field.
			var xmlValue = control.getAttribute( "xml_value" );
			if( xmlValue != null ){
				xmlField.value = xmlValue;
            } else {
                //If there is no xml_value, use the control value directly.
                xmlField.value = control.value;
			}
		}else if( type == "checkbox" ){
			if( control.checked ){
				//CID 0125 //2008.09.28 //Begin
				xmlField.value = InfoJet_GetOnOffValue( control, true );
				//CID 0125 //2008.09.28 //End
			}else{
				//CID 0125 //2008.09.28 //Begin
				xmlField.value = InfoJet_GetOnOffValue( control, false );
				//CID 0125 //2008.09.28 //End
			}
		}else if( type == "radio" ){
			if( control.checked ){
				//CID 0125 //2008.09.28 //Begin
				xmlField.value = InfoJet_GetOnOffValue( control, true );
				//CID 0125 //2008.09.28 //End
			}
		}
	}else if( tagName == "textarea" ){
		//CID 0092 //2008.08.14 //Begin
		var xmlValue = control.getAttribute( "xml_value" );
		if( xmlValue != null ){
			xmlField.value = xmlValue;
		}else{
		//CID 0092 //2008.08.14 //End
			xmlField.value = control.value;
		}
	}else{
		//CID 0045 //2008.07.24 //Begin
		xmlField.value = control.innerHTML;
		//CID 0045 //2008.07.24 //End
	}
	InfoJet_UpdateXDocumentDOM( xmlField );
}

//CID 0125 //2008.09.28 //Begin
function InfoJet_GetOnOffValue( control, isOn ){
	var attr = null;
	if( isOn ){
		attr = InfoJet_XdPrefix + "onValue";
	}else{
		attr = InfoJet_XdPrefix + "offValue";
	}
	var value = control.getAttribute( attr );
	if( value != null ){
		return value;
	}else{
		return "";
	}
}
//CID 0125 //2008.09.28 //End

function InfoJet_HideOverBorderArrow(){
	//CID 0673 //2010.09.29 //Begin
	InfoJet_FieldOverLeft.style.height = 0;
	InfoJet_FieldOverRight.style.height = 0;
	InfoJet_FieldOverTop.style.width = 0;
	InfoJet_FieldOverBottom.style.width = 0;
	InfoJet_ItemOverLeft.style.height = 0;
	InfoJet_ItemOverRight.style.height = 0;
	InfoJet_ItemOverTop.style.width = 0;
	InfoJet_ItemOverBottom.style.width = 0;
	//CID 0673 //2010.09.29 //End
	//CID 0010 //2008.06.05 //Begin
	//InfoJet_HideOverMenuArrow();
	//CID 0010 //2008.06.05 //End
}

function InfoJet_HideFocusBorderArrow() {
    //CID 0673 //2010.09.29 //Begin
    InfoJet_FieldFocusLeft.style.height = 0;
    InfoJet_FieldFocusRight.style.height = 0;
    InfoJet_FieldFocusTop.style.width = 0;
    InfoJet_FieldFocusBottom.style.width = 0;
    InfoJet_ItemFocusLeft.style.height = 0;
    InfoJet_ItemFocusRight.style.height = 0;
    InfoJet_ItemFocusTop.style.width = 0;
    InfoJet_ItemFocusBottom.style.width = 0;
    //CID 0673 //2010.09.29 //End
	InfoJet_HideFocusMenuArrow();	
}

function InfoJet_SelectTextControlPlaceHolder( control ){
	var ghosted = control.getAttribute( InfoJet_XdPrefix + "ghosted" );
	if( ghosted != null && ghosted == "true" ){
		control.createTextRange().select();
	}
}

function InfoJet_DisableContextMenu( event ){
	event = InfoJet_GetEvent( event );
	event.cancelBubble = true;
	event.returnValue = false;
}

//CID 0500 //2010.08.24 //Begin
function InfoJet_GetPSVI(element) {
    if (InfoJet_PSVITable != null) {
        var psviId = element.getAttribute("psvi_id");
        if (psviId != null && psviId.length > 0) {
            var psvi = InfoJet_PSVITable[psviId];
            return psvi;
        }
    }
    return null;
}
//CID 0500 //2010.08.24 //End

//CID 0500 //2010.07.29 //Begin
function InfoJet_GetSchemaType(element) {
    var psvi = InfoJet_GetPSVI(element);
    if (psvi != null) {
        return psvi.type;
    }
    var schemaType = element.getAttribute("schema_type");
    //CID 0970 //2011.07.03 //||
    if (schemaType == null || schemaType.length <= 0) {
        schemaType = "unknown";
    }
    return schemaType;
}
//CID 0500 //2010.07.29 //End

//CID 0500 //2010.07.29 //Begin
function InfoJet_GetSchemaNillable(element) {
    var psvi = InfoJet_GetPSVI(element);
    if (psvi != null) {
        return psvi.nillable;
    }
    var schemaNillable = element.getAttribute("schema_nillable");
    if (schemaNillable == null && schemaNillable.length <= 0) {
        schemaNillable = "unknown";
    }
    return schemaNillable;
}
//CID 0500 //2010.07.29 //End

//CID 0500 //2010.08.24 //Begin
function InfoJet_GetSchemaMinLength(element) {
    var psvi = InfoJet_GetPSVI(element);
    if (psvi != null) {
        return psvi.minLength;
    }
    var minLength = element.getAttribute("schema_minLength");
    return minLength;
}
//CID 0500 //2010.08.24 //End

//CID 0500 //2010.08.24 //Begin
function InfoJet_GetSchemaMaxLength(element) {
    var psvi = InfoJet_GetPSVI(element);
    if (psvi != null) {
        return psvi.maxLength;
    }
    var minLength = element.getAttribute("schema_maxLength");
    return minLength;
}
//CID 0500 //2010.08.24 //End

//CID 0629 //2010.08.02 //Begin
function InfoJet_CheckOnChangeTable(element) {
    if (InfoJet_OnChangeTable != null) {
        for (var nodeName in InfoJet_OnChangeTable) {
            if (InfoJet_EndsWith( element.id, nodeName )) {
                var fieldId = "xdoc" + InfoJet_GetElementId(element);
                var xmlField = document.getElementById(fieldId);
                if (xmlField != null) {
                    var sender = { control:element, field:xmlField };
                    var args = { newValue: xmlField.value };
                    return InfoJet_OnChangeTable[nodeName].call(null, sender, args);
                }
            }
        }
    }
    return true;
}
//CID 0629 //2010.08.02 //End

//CID 0257 //2009.03.23 //Begin
function InfoJet_IsComboBoxControl( control ){
	if( control.className != null && control.className.indexOf( "xdComboBox" ) == 0 ){
		//CID 0255 //2009.05.19 //InfoJet_GetPreviousElement( control );
		var previousElement = InfoJet_GetPreviousElement( control );
		if( previousElement ){
			var tagName = previousElement.tagName.toLowerCase();
			//CID 0255 //2009.05.19 //"input"
			if( tagName == "input" ){
				if( previousElement.className != null && previousElement.className.indexOf( "ComboBoxTextField" ) > 0 ){
					return true;
				}
			}
		}
	}
	if( control.className != null && control.className.indexOf( "ComboBoxTextField" ) > 0 ){
		//CID 0255 //2009.05.19 //InfoJet_GetNextElement( control );
		var nextElement = InfoJet_GetNextElement( control );
		if( nextElement ){
			var tagName = nextElement.tagName.toLowerCase();
			if( tagName == "select" ){
				if( nextElement.className != null && nextElement.className.indexOf( "xdComboBox" ) == 0 ){
					return true;
				}
			}
		}
	}	
	return false;
}
//CID 0257 //2009.03.23 //End

//CID 0232 //2009.02.19 //Begin
function InfoJet_UpdateComboBox( control ){
	if( control.className != null && control.className.indexOf( "xdComboBox" ) == 0 ){
		//CID 0255 //2009.05.19 //InfoJet_GetPreviousElement( control );
		var textField = InfoJet_GetPreviousElement( control );
		if( textField != null ){
			textField.value = control.options[ control.selectedIndex ].text;
		}
		return true;
	}else if( control.className != null && control.className.indexOf( "ComboBoxTextField" ) > 0 ){
		//CID 0255 //2009.05.19 //InfoJet_GetNextElement( control );
		var select = InfoJet_GetNextElement( control );
		//CID 0251 //2009.03.16 //Begin
		for( var i = 0; i < select.options.length; i++ ){
			var optionValue = select.options[i].value;
			if( optionValue != null && optionValue == control.value ) {
				select.options[i].selected = true;
			}else{
				select.options[i].selected = false;
			}
		}
		//CID 0223 //2009.03.17 //Begin
		select.value = control.value;
		//CID 0223 //2009.03.17 //End
		//CID 0251 //2009.03.16 //End
		return true;
	}else{
		return false;
	}
}
//CID 0232 //2009.02.19 //End

function InfoJet_OnControlChange(event, control) {
    //CID 0365 //2009.07.14 //Begin
    var postbacked = control.getAttribute("postbacked");
    if (postbacked != null && postbacked == "true") {
        return;
    }
    //CID 0365 //2009.07.14 //End
    InfoJet_MoveProgress2ControlPosition(control);
    InfoJet_TrimByMaxLength(control);
	//CID 0223 //2009.03.17 //Begin
	var isComboBoxControl = InfoJet_IsComboBoxControl( control );
	if( isComboBoxControl ){
		InfoJet_UpdateComboBox( control );
	}
	//CID 0223 //2009.03.17 //End
	//CID 0741 //2011.03.08 //Begin
	InfoJet_CheckGhosted(control);
	//CID 0741 //2011.03.08 //End
	//CID 0332 //2009.08.11 //Begin
	InfoJet_CheckPostback( control, isComboBoxControl, true );
	//CID 0332 //2009.08.11 //End
}

//CID 0332 //2009.08.11 //Begin
function InfoJet_CheckPostback( control, isComboBoxControl, isCheckingSchema ){
	var needsLogicPostback = InfoJet_CheckLogicPostback( control, isComboBoxControl );
	var needsSchemaPostback = false;
	if( isCheckingSchema ){
	    needsSchemaPostback = InfoJet_UpdateBySchema(control, needsLogicPostback);
	    //CID 0629 //2010.08.02 //Begin
	    if (!InfoJet_CheckOnChangeTable(control)) {
	        return;
	    }
	    //CID 0629 //2010.08.02 //End
	    //CID 0773 //2011.01.29 //Begin
	    if (typeof (InfoJetCustom_OnControlChange) != "undefined") {
	        if (!InfoJetCustom_OnControlChange(control)) {
	            return;
	        }
	    }
	    //CID 0773 //2011.01.29 //End
	}
	//CID 0793 //2011.02.16 //Begin
	var forcePostback = false;
	var forcePostbackValue = control.getAttribute("InfoJet_ForcePostback");
	if (forcePostbackValue != null && forcePostbackValue.toLowerCase() == "true") {
	    forcePostback = true;
	}
	var forcePostbackOnceValue = control.getAttribute("InfoJet_ForcePostbackOnce");
	if (forcePostbackOnceValue != null && forcePostbackOnceValue.toLowerCase() == "true") {
	    forcePostback = true;
	    control.removeAttribute("InfoJet_ForcePostbackOnce");
	}
	//CID 0793 //2011.02.17 //End
	//CID 0793 //2011.02.16 //if
	if (needsLogicPostback || needsSchemaPostback || forcePostback) {
		InfoJet_CheckOldValueState( control );
		//CID 0291 //2009.05.31 //InfoJet_UseAjax
		if( InfoJet_UseAjax ){
			InfoJet_AJAXonField( control );
		}else{
			InfoJet_RefreshAfaterUpdate( control );
		}
	}
}
//CID 0332 //2009.08.11 //End

//CID 0332 //2009.08.11 //Begin
function InfoJet_CheckLogicPostback( control, isComboBoxControl ){
	var logicTags = control.getAttribute( "logic_tags" );
	if( logicTags != null && logicTags.length > 0 ){
		return true;
	}
	var isDuplicateId = control.getAttribute( "duplicate_id" );
	if( isDuplicateId != null && isDuplicateId == "yes" ){
		//CID 0232 //2009.02.19 //Begin
		if( InfoJet_IsRadioButton( control ) ){
			//continue.
		}else if( isComboBoxControl ){
			//continue.
		}else{
			//CID 0290 //2009.05.25 //"V"
			return true;
		}
		//CID 0232 //2009.02.19 //End
	}
	var isServerControl = control.getAttribute( "server_control" );
	if( isServerControl == null || isServerControl == "yes" ){
		//CID 0290 //2009.05.25 //"V"
		return true;
	}
	return false;
}
//CID 0332 //2009.08.11 //End

function InfoJet_UpdateBySchema( control, needsLogicPostback ){
	//InfoJet_UpdateBySchema返回值,标识是否需要Postback.
	//在InfoJet_UpdateBySchema中已经调用过InfoJet_XmlValueFormatted和InfoJet_UpdateField,InfoJet_OnControlChange中不需要再调用.
    //CID 0500 //2010.07.29 //Begin
    var schemaType = InfoJet_GetSchemaType(control);
    //CID 0500 //2010.07.29 //End
	if( schemaType == "unknown" ){
		//Schema未知,post-back
		InfoJet_XmlValueFormatted( false );
		InfoJet_UpdateField( control );
		return true;
	}
	var dataFmtResult = InfoJet_DataFmt( control );
	//CID 0252 //2009.03.17 //Begin
	if( dataFmtResult == - 1 && schemaType == "string" ){
		dataFmtResult = 1;
	}
	//CID 0252 //2009.03.17 //End
	if( dataFmtResult == 0 ){
		//不支持的格式,post-back
		InfoJet_XmlValueFormatted( false );
		InfoJet_UpdateField( control );
		return true;
	}else if( dataFmtResult == 1 ){
	    //支持的格式
	    //CID 0500 //2010.08.02 //Begin
	    var schemaNillable = InfoJet_GetSchemaNillable(control);
	    //CID 0500 //2010.08.02 //End
		var controlValue = InfoJet_GetControlValue( control );
		if( controlValue == null ){
			return false;
		}
		//CID 0332 //2009.08.11 //if
		if( !needsLogicPostback ){
			if( controlValue.length > 0 ){
				if( schemaNillable == "true" ){
					InfoJet_RemoveError( control.id, 'schema' );
					InfoJet_HideError( control.id );
	            } else {
	                //CID 1131 //2012.03.13 //controlValue
					if( InfoJet_CheckSchemaLength( control, controlValue ) ){
						InfoJet_RemoveError( control.id, 'schema' );
						InfoJet_HideError( control.id );
					}else{
						InfoJet_AddSchemaError( control.id );
						InfoJet_ShowSchemaError( control.id );
					}
				}
			}else{
				if( schemaNillable == "true" ){
					InfoJet_RemoveError( control.id , 'schema' );
					InfoJet_HideError( control.id  );
				}else{
					if( schemaType == "string" || schemaType == "anyURI" ){
					    //CID 1131 //2012.03.13 //controlValue
					    if (InfoJet_CheckSchemaLength(control, controlValue)) {
							InfoJet_RemoveError( control.id, 'schema' );
							InfoJet_HideError( control.id );
						}else{
							InfoJet_AddSchemaError( control.id );
							InfoJet_ShowSchemaError( control.id );
						}
					}else{ // "" is invalidate for other schema type fields
						InfoJet_AddSchemaError( control.id );
						InfoJet_ShowSchemaError( control.id );
					}
				}
			}
		}
		InfoJet_XmlValueFormatted( true );
		InfoJet_UpdateField( control );
		return false;
	}else{ // -1
		//错误的格式
		//CID 0332 //2009.08.11 //if
		if( !needsLogicPostback ){
			InfoJet_AddSchemaError( control.id );
			InfoJet_ShowSchemaError( control.id );
		}
		
		InfoJet_XmlValueFormatted( false );
		InfoJet_UpdateField( control );
		return false;
	}
	return false;
}

function InfoJet_XmlValueFormatted( formatted )
{
	if( formatted ){
		document.getElementById( "xdoc_param_xml_value_formatted" ).value = "1";
	}else{
		document.getElementById( "xdoc_param_xml_value_formatted" ).value = "0";
	}
}

function InfoJet_IsRadioButton( control ){
	var tagName = control.tagName.toLowerCase();
	if( tagName == "input" ){
		var type = control.type.toLowerCase();
		if( type == "radio" ){
			return true;
		}
	}
	return false;
}

function InfoJet_GetControlValue( control ){
	var tagName = control.tagName.toLowerCase();
	if( tagName == "select" ){
		//CID 0382 //2009.09.22 //Begin
		return InfoJet_GetHtmlSelectValue( control );
		//CID 0382 //2009.09.22 //End
	}else if( tagName == "img" ){
		return control.src;
	}else if( tagName == "input" ){
		var type = control.type.toLowerCase();
		if( type == "text" || type == "password" ){
			return control.value;
		}else if( type == "checkbox" ){
			if( control.checked ){
				//CID 0125 //2008.09.28 //Begin
				return InfoJet_GetOnOffValue( control, true );
				//CID 0125 //2008.09.28 //End
			}else{
				//CID 0125 //2008.09.28 //Begin
				return InfoJet_GetOnOffValue( control, false );
				//CID 0125 //2008.09.28 //End
			}
		}else if( type == "radio" ){
			if( control.checked ){
				//CID 0125 //2008.09.28 //Begin
				return InfoJet_GetOnOffValue( control, true );
				//CID 0125 //2008.09.28 //End
			}
		}
	}else if( tagName == "textarea" ){
		return control.value;
	}else{
		//CID 0045 //2008.07.24 //Begin
		return control.innerHTML
		//CID 0045 //2008.07.24 //End
	}
}

//CID 1131 //2012.03.13 //controlValue
function InfoJet_CheckSchemaLength( control, controlValue ){
	var checkMinLength = true;
	var checkMaxLength = true;
	//CID 0500 //2010.08.24 //Begin
	var minLengthValue = InfoJet_GetSchemaMinLength(control);
	//CID 0500 //2010.08.24 //End
	if( minLengthValue != null && minLengthValue.length > 0 ){
		if( minLengthValue != "unbounded" ){
			var minLength = parseInt( minLengthValue );
			if (controlValue.length < minLength) {
				checkMinLength = false;
			}
		}
	}
	//CID 0500 //2010.08.24 //Begin
	var maxLengthValue = InfoJet_GetSchemaMaxLength(control);
	//CID 0500 //2010.08.24 //End
	if (maxLengthValue != null && maxLengthValue.length > 0) {
		if( maxLengthValue != "unbounded" ){
			var maxLength = parseInt( maxLengthValue );
			if (controlValue.length > maxLength) {
				checkMaxLength = false;
			}
		}
	}
	return checkMinLength && checkMaxLength;
}
//CID 1131 //2012.03.13 //End

//CID 0741 //2011.03.08 //Begin
function InfoJet_CheckGhosted(control) {
    if (InfoJet_IsTextControl(control)) {
        var ghosted = control.getAttribute(InfoJet_XdPrefix + "ghosted");
        if (ghosted != null && ghosted == "true") {
            control.setAttribute(InfoJet_XdPrefix + "ghosted", "false");
            //CID 0741 //2011.03.08 //Begin
            var noneghostedcolor = control.getAttribute("noneghostedcolor");
            if (noneghostedcolor != null) {
                control.style.color = noneghostedcolor;
            }
            //CID 0741 //2011.03.08 //End
        }
    }
}
//CID 0741 //2011.03.08 //End

function InfoJet_OnLinkedPictureClick(event, linkedPicture) {
	if( typeof(InfoJetCustom_OnLinkedPictureClick) != "undefined" ){
		eval( "InfoJetCustom_OnLinkedPictureClick( event , linkedPicture );" );
    } else {
        //CID 1424 //2012.11.02 //Begin 
        var oldSrc = "";
        if (linkedPicture.tagName.toLowerCase() == "img") {
            //CID 1483 //2012.12.06 //Begin
            oldSrc = linkedPicture.src;
            //CID 1483 //2012.12.06 //End
        }
        window.showModalDialog(InfoJet_WebContext + "js/linkpicture_dialog.htm", new Array(window, linkedPicture, oldSrc), 'dialogWidth:470px;dialogHeight:150px;help:no;');
        if (linkedPicture.linkPicturePath) {
            //CID 1483 //2012.12.06 //var
            var src = linkedPicture.linkPicturePath.substr(5);
            linkedPicture.removeAttribute("linkPicturePath");
            //CID 1424 //2012.11.02 //End
            if (src != null) {
                //CID 1429 //2012.11.02 //Begin
                if (InfoJet_EnablePlaceholderUI) {
                    var fieldId = "xdoc" + InfoJet_GetElementId(linkedPicture);
                    var xmlField = InfoJet_GetWriteOnlyField(fieldId);
                    xmlField.value = src;
                    InfoJet_PostbackOnControl(linkedPicture);
                } else {
                    linkedPicture.src = src;
                    InfoJet_UpdateField(linkedPicture);
                }
                //CID 1429 //2012.11.02 //End
            }
        }
	}
}

function InfoJet_OnInlinePictureClick( event, inlinePicture ){
	//CID 0002 //2008.06.04 //Begin
	var disableEditing = inlinePicture.getAttribute( InfoJet_XdPrefix + "disableEditing" );
	if( disableEditing != null && disableEditing.toLowerCase() == "yes" ){
		return;
	}
	//CID 0002 //2008.06.04 //End
	if( typeof(InfoJetCustom_OnInlinePictureClick) != "undefined" ){
		//CID 0033 //2008.06.28 //Begin
		var formId = document.getElementById( "xdoc_param_form_id" ).value;
		eval( "InfoJetCustom_OnInlinePictureClick( event , inlinePicture, formId );" );
		//CID 0033 //2008.06.28 //End
	}else{
		//CID 0033 //2008.06.28 //Begin
		var formId = document.getElementById( "xdoc_param_form_id" ).value;
		//CID 0030 //2008.07.14 //Begin
		var uploadedPicture = window.showModalDialog( InfoJet_WebContext + "js/uploadpicture_dialog.htm", new Array( window, inlinePicture, formId ), 'dialogWidth:470px;dialogHeight:150px;help:no;' );
		if (uploadedPicture != null) {
		    //CID 1422 //2012.10.31 //Begin
		    if (InfoJet_EnablePlaceholderUI) {
		        var pureId = InfoJet_GetPureId(inlinePicture.id);
		        var file = InfoJet_GetWriteOnlyField("xdoc" + pureId);
		        file.value = uploadedPicture.content;
		        InfoJet_PostbackOnControl(inlinePicture);
		    } else {
		        InfoJet_LinkUploadedPicture(inlinePicture, uploadedPicture);
		        //CID 0861 //2011.04.12 //Begin
		        var psvi = InfoJet_GetPSVI(inlinePicture);
		        if (psvi != null && psvi.type == "base64Binary" && psvi.nillable == "false") {
		            InfoJet_RemoveError(inlinePicture.id, 'schema');
		            InfoJet_HideError(inlinePicture.id);
		        }
		        window.setTimeout("InfoJet_RelayoutFieldStyles();InfoJet_ShowFieldBorder( document.getElementById('" + inlinePicture.id + "'), 'xdoc_field_focus' );", 500);
		        //CID 0861 //2011.04.13 //End
            
            }
		    //CID 1422 //2012.10.31 //End
		}
		//CID 0030 //2008.07.14 //End
		//CID 0033 //2008.06.28 //End
    }
}

//CID 0030 //2008.07.14 //Begin
function InfoJet_LinkUploadedPicture(inlinePicture, uploadedPicture) {
    if( inlinePicture.src == null )
	{
		inlinePicture = document.getElementById( pureId + ",1" );
	}
	var linkPath = uploadedPicture.path;
	inlinePicture.src = linkPath;
	var pureId = InfoJet_GetPureId( inlinePicture.id );
	//CID 0664 //2010.11.01 //Begin
	var file = InfoJet_GetWriteOnlyField("xdoc" + pureId);
	file.value = uploadedPicture.content;
	//CID 0664 //2010.11.01 //End
	//CID 0496 //2010.02.05 //Begin
	InfoJet_UpdateXDocumentDOM( file );
	//CID 0496 //2010.02.05 //End
}
//CID 0030 //2008.07.14 //End

//CID 0499 //2010.03.17 //Begin
function InfoJet_OnInkPictureClick(event, inkPicture) {
    //CID 0860 //2011.04.14 //Begin
    var disableEditing = inkPicture.getAttribute(InfoJet_XdPrefix + "disableEditing");
    if (disableEditing != null && disableEditing.toLowerCase() == "yes") {
        return;
    }
    //CID 0860 //2011.04.14 //End
    //CID 1571 //2013.01.21 //Begin
    if (!InfoBus_EnsureInkActiveX()) {
        return;
    }
    //CID 1571 //2013.01.21 //End
	var formId = document.getElementById( "xdoc_param_form_id" ).value;
	var backgroundPicture = InfoJet_GetPreviousElement( inkPicture );
	if( backgroundPicture != null ){
		var isBackground = backgroundPicture.getAttribute( "isBackground" );
		if( isBackground == null || isBackground != "true" ){
			backgroundPicture = null;
		}
	}
	var width = inkPicture.offsetWidth + 50;
	var height = inkPicture.offsetHeight + 65;
	if( width > 800 ){ width = 800; }
	if( height > 700 ){ height = 700; }
	if( width < 270 ){ width = 270; }
	if( height < 250 ){ height = 250; }
	var uploadedPicture = window.showModalDialog( InfoJet_WebContext + "js/ink_dialog.htm", new Array( window, backgroundPicture, inkPicture, formId ), 'dialogWidth:' + width + 'px;dialogHeight:' + height + 'px;resizable:yes;help:no;' );
	if( uploadedPicture != null ){
	    InfoJet_LinkUploadedPicture(inkPicture, uploadedPicture);
	    //CID 0861 //2011.04.12 //Begin
	    var psvi = InfoJet_GetPSVI(inkPicture);
	    if (psvi != null && psvi.type == "base64Binary" && psvi.nillable == "false") {
	        InfoJet_RemoveError(inkPicture.id, 'schema');
	        InfoJet_HideError(inkPicture.id);
	    }
	    //CID 0861 //2011.04.12 //End
	}
}
//CID 0499 //2010.03.17 //End

//CID 1535 //2013.01.12 //Begin
function InfoBus_EnsureInkActiveX() {
    if (InfoJet_IsIE()) {
        var toInstall = false;
        try {
            var control = new ActiveXObject("InfoBus.InkPicture.InkPictureControl1");
            if (control == null) {
                toInstall = true;
            }
        } catch (c) {
            toInstall = true;
        }
        if (toInstall) {
            return InfoBus_InstallInkActiveX();
        } else {
            return true;
        }
    } else {
        alert("Please use the ink control in Internet Explorer.");
        return false;
    }
}
//CID 1535 //2013.01.12 //End

//CID 1535 //2013.01.12 //Begin
function InfoBus_InstallInkActiveX() {
    var result = window.showModalDialog(InfoJet_WebContext + 'js/ink_install_dialog.htm', new Array(), 'dialogWidth:455px;dialogHeight:380px;resizable:yes;help:no;');
    return result;
}
//CID 1535 //2013.01.12 //End

//CID 0499 //2010.03.17 //Begin
function InfoJet_SetInkPictures( backgroundData, inkData ){
	if( InfoJet_CurrentDialog != null ){
		InfoJet_CurrentDialog.SetInkPictures( backgroundData, inkData );
	}	
}
//CID 0499 //2010.03.17 //End

//CID 0820 //2011.03.29 //Begin
function InfoJet_IsAncestorElementDisabled(source, ancestorTagName) {
    var ancestor = InfoJet_GetParent(source);
    while (ancestor) {
        if (ancestor.tagName) {
            if (ancestor.tagName.toLowerCase() == ancestorTagName) {
                if (ancestor.disabled) {
                    return true;
                }
            }
            ancestor = InfoJet_GetParent(ancestor);
        } else {
            break;
        }
    }
    return false;
}
//CID 0820 //2011.03.29 //End

//CID 0749 //2011.08.30 //Begin
//CID 1536 //2013.01.09 //Begin
var InfoBus_SignatureScreenInfo = null;
//CID 1536 //2013.01.09 //End
//CID 0749 //2011.08.30 //End

//CID 1536 //2013.01.09 //Begin
function InfoBus_SetSignatureScreenInfo() {
    InfoBus_SignatureScreenInfo = {};
    var context = InfoBus_GetIFrameContext();
    if (context != null) {
        InfoBus_SignatureScreenInfo.documentElement = parent.document.documentElement;
        InfoBus_SignatureScreenInfo.width = parent.document.documentElement.clientWidth;
        InfoBus_SignatureScreenInfo.height = parent.document.documentElement.clientHeight;
    } else {
        InfoBus_SignatureScreenInfo.documentElement = document.body;
        InfoBus_SignatureScreenInfo.width = document.body.offsetWidth;
        InfoBus_SignatureScreenInfo.height = document.body.offsetHeight;
    }
}
//CID 1536 //2013.01.09 //End

//CID 0749 //2011.08.30 //Begin
function InfoJet_OnSignatureButtonClick(event, button, isSignatureLine) {
    if (InfoJet_CheckClickFrequently(button)) {
        return;
    }
    //CID 1036 //2012.01.07 //Begin
    //CID 1535 //2013.01.12 //Begin
    if (!InfoBus_EnsureSignatureActiveX()) {
        return;
    }
    //CID 1535 //2013.01.12 //End
    //CID 1536 //2013.01.09 //Begin
    InfoBus_SetSignatureScreenInfo();
    //CID 1536 //2013.01.09 //End
    //CID 1036 //2012.01.07 //End
    var block = button.getAttribute("dsig_block");
    var blockField = document.getElementById("xdoc_param_dsig_block");
    if (blockField == null) {
        var xdocForm = document.getElementById("xdoc_form");
        var blockHtml = "<input type=hidden id=xdoc_param_dsig_block name=xdoc_param_dsig_block />";
        InfoJet_InsertAdjacentHTMLBeforeEnd(xdocForm, blockHtml);
        blockField = document.getElementById("xdoc_param_dsig_block");
    }
    blockField.value = block;
    //CID 1503 //2012.12.21 //Begin
    if (isSignatureLine) {
        var isline = document.getElementById("xdoc_param_dsig_isline");
        if (isline == null) {
            var xdocForm = document.getElementById("xdoc_form");
            var islineHtml = "<input type=hidden id=xdoc_param_dsig_isline name=xdoc_param_dsig_isline />";
            InfoJet_InsertAdjacentHTMLBeforeEnd(xdocForm, islineHtml);
            isline = document.getElementById("xdoc_param_dsig_isline");
        }
        isline.value = "true";
    }
    //CID 1503 //2012.12.21 //End
    document.getElementById("xdoc_param_command").value = "Update_PrepareSignature";
    InfoJet_MoveProgress2ControlPosition(button);
    InfoJet_Submit();
}
//CID 0749 //2011.08.30 //End

//CID 1535 //2013.01.12 //Begin
function InfoBus_EnsureSignatureActiveX() {
    if (InfoJet_IsIE()) {
        var toInstall = false;
        try {
            var control = new ActiveXObject("InfoBus.DigitalSignature.DSignControl1");
            if (control == null) {
                toInstall = true;
            }
        } catch (c) {
            toInstall = true;
        }
        if (toInstall) {
            return InfoBus_InstallSignatureActiveX();
        } else {
            return true;
        }
    } else {
        alert("Please add the digital signature in Internet Explorer.");
        return false;
    }
}
//CID 1535 //2013.01.12 //End

//CID 1535 //2013.01.12 //Begin
function InfoBus_InstallSignatureActiveX() {
    var result = window.showModalDialog(InfoJet_WebContext + 'js/signature_install_dialog.htm', new Array(), 'dialogWidth:455px;dialogHeight:380px;resizable:yes;help:no;');
    return result;
}
//CID 1535 //2013.01.12 //End

//CID 0749 //2011.08.30 //Begin
function InfoJet_ToSign(dsigData) {
    window.showModalDialog(InfoJet_WebContext + 'js/signature_dialog.htm', new Array(window, dsigData, true), 'dialogWidth:455px;dialogHeight:530px;resizable:yes;help:no;');
}
//CID 0749 //2011.08.30 //End

//CID 0749 //2011.08.30 //Begin
function InfoJet_OnSigned(blockName, signedXml) {
    var xdocForm = document.getElementById("xdoc_form");
    var blockField = document.getElementById("xdoc_param_dsig_block");
    if (blockField == null) {
        var blockHtml = "<input type=hidden id=xdoc_param_dsig_block name=xdoc_param_dsig_block />";
        InfoJet_InsertAdjacentHTMLBeforeEnd(xdocForm, blockHtml);
        blockField = document.getElementById("xdoc_param_dsig_block");
    }
    blockField.value = blockName;
    var xmlField = document.getElementById("xdoc_param_dsig_xml");
    if (xmlField == null) {
        var xmlHtml = "<input type=hidden id=xdoc_param_dsig_xml name=xdoc_param_dsig_xml />";
        InfoJet_InsertAdjacentHTMLBeforeEnd(xdocForm, xmlHtml);
        xmlField = document.getElementById("xdoc_param_dsig_xml");
    }
    xmlField.value = signedXml;
    document.getElementById("xdoc_param_command").value = "Update_AddSignature";
    InfoJet_Submit();
}
//CID 0749 //2011.08.30 //End

//CID 0749 //2011.08.30 //Begin
function InfoJet_DeleteSignature(target) {
    if (InfoJet_CheckClickFrequently(target)) {
        return;
    }
    //CID 1519 //2012.12.29 //Begin
    var dsigId = null;
    if (target.tagName.toLowerCase() == "a") {
        target = InfoJet_GetParent(target);
        dsigId = target.id;
    } else {
        dsigId = target.id;
        target = InfoJet_GetLastChild(target);
    }
    //CID 1519 //2012.12.29 //End
    if (window.confirm("Do you confirm to delete this signature?")) {
        var xdocForm = document.getElementById("xdoc_form");
        var idField = document.getElementById("xdoc_param_dsig_sigid");
        if (idField == null) {
            var xmlHtml = "<input type=hidden id=xdoc_param_dsig_sigid name=xdoc_param_dsig_sigid />";
            InfoJet_InsertAdjacentHTMLBeforeEnd(xdocForm, xmlHtml);
            idField = document.getElementById("xdoc_param_dsig_sigid");
        }
        idField.value = InfoJet_GetPureId(dsigId);
        document.getElementById("xdoc_param_command").value = "Update_DeleteSignature";
        InfoJet_MoveProgress2ControlPosition(target);
        InfoJet_Submit();
    }
}
//CID 0749 //2011.08.30 //End

//CID 0749 //2011.08.30 //Begin
function InfoJet_ShowSignatureDetails(target) {
    if (InfoJet_CheckClickFrequently(target)) {
        return;
    }
    //CID 1503 //2012.12.22 //Begin
    var dsigId = null;
    if (target.tagName.toLowerCase() == "button") {
        dsigId = target.getAttribute("dsig_id");
    } else {
        //CID 1519 //2012.12.29 //Begin
        var parent = InfoJet_GetParent(target);
        dsigId = parent.id;
        //CID 1519 //2012.12.29 //End
    }
    //CID 1503 //2012.12.22 //End
    var xdocForm = document.getElementById("xdoc_form");
    var idField = document.getElementById("xdoc_param_dsig_sigid");
    if (idField == null) {
        var xmlHtml = "<input type=hidden id=xdoc_param_dsig_sigid name=xdoc_param_dsig_sigid />";
        InfoJet_InsertAdjacentHTMLBeforeEnd(xdocForm, xmlHtml);
        idField = document.getElementById("xdoc_param_dsig_sigid");
    }
    idField.value = InfoJet_GetPureId(dsigId);
    document.getElementById("xdoc_param_command").value = "Update_ViewSignature";
    InfoJet_MoveProgress2ControlPosition(target);
    InfoJet_Submit();
}
//CID 0749 //2011.08.30 //End

//CID 0749 //2011.09.21 //Begin
function InfoJet_ViewSignature(signedData) {
    window.showModalDialog(InfoJet_WebContext + 'js/signature_dialog.htm', new Array(window, signedData, false), 'dialogWidth:455px;dialogHeight:430px;resizable:yes;help:no;');
}
//CID 0749 //2011.09.21 //End

//CID 0656 //2010.10.17 //Begin
function InfoJet_OnPNGPickerClick(event, pngAddressButton) {
    //CID 0820 //2011.03.29 //Begin
    if (InfoJet_IsAncestorElementDisabled(pngAddressButton, "span")) {
        return;
    }
    //CID 0820 //2011.03.29 //End
    var tr = InfoJet_GetParent(InfoJet_GetParent(pngAddressButton));
    var pngId = tr.getAttribute("pngId");
    var allowMultiple = tr.getAttribute("allowMultiple");
    var xml = window.showModalDialog(InfoJet_WebContext + "js/pngpicker_dialog.htm", new Array(window, pngId, allowMultiple), 'dialogWidth:570px;dialogHeight:390px;resizable:yes;help:no;');
    if (xml) {
        //CID 0828 //2011.03.10 //Begin
        InfoJet_FocusItemIndex = -1;
        var box = InfoJet_GetElements(InfoJet_GetElements(tr)[0])[0];
        InfoJet_FocusControlId = box.id;
        //CID 0828 //2011.03.10 //End
        var xdocForm = document.getElementById("xdoc_form");
        var xmlHtml = "<input type=hidden id=xdoc_param_png_added_xml name=xdoc_param_png_added_xml />";
        InfoJet_InsertAdjacentHTMLBeforeEnd(xdocForm, xmlHtml);
        document.getElementById("xdoc_param_png_added_xml").value = xml;
        var contextIdHtml = "<input type=hidden id=xdoc_param_png_context_id name=xdoc_param_png_context_id />";
        InfoJet_InsertAdjacentHTMLBeforeEnd(xdocForm, contextIdHtml);
        //CID 0858 //2011.03.29 //Begin
        document.getElementById("xdoc_param_png_context_id").value = tr.id;
        //CID 0858 //2011.03.29 //End
        var pngIdHtml = "<input type=hidden id=xdoc_param_png_id name=xdoc_param_png_id />";
        InfoJet_InsertAdjacentHTMLBeforeEnd(xdocForm, pngIdHtml);
        document.getElementById("xdoc_param_png_id").value = pngId;
        document.getElementById("xdoc_param_command").value = "Update_AddPrincipals";
        InfoJet_MoveProgress2ControlPosition(tr);
        InfoJet_Submit();
    }
}
//CID 0656 //2010.10.21 //End

//CID 0656 //2010.10.21 //Begin
function InfoJet_ShowPNGPrincipals(principals) {
    if (InfoJet_CurrentDialog != null) {
        InfoJet_CurrentDialog.ShowPrincipals(principals);
    }
}
//CID 0656 //2010.10.21 //End

//CID 0656 //2010.10.22 //Begin
function InfoJet_OnPNGItemClick(item) {
    //CID 0820 //2011.03.29 //Begin
    if (InfoJet_IsAncestorElementDisabled(item, "span")) {
        return false;
    }
    //CID 0820 //2011.03.29 //End
    //CID 0754 //2011.01.18 //Begin
    var tr = InfoJet_GetParent(InfoJet_GetParent(InfoJet_GetParent(item)));
    var button = InfoJet_GetFirstChild(InfoJet_GetLastChild(tr));
    if (button.disabled) {
        return false;
    }
    //CID 0754 //2011.01.18 //End
    item.style.backgroundColor = "blue";
    item.style.color = "#FFFFFF";
    var img = InfoJet_GetElements(item)[0];
    img.style.display = "";
    return false;
}
//CID 0656 //2010.10.22 //End

//CID 0828 //2011.03.10 //Begin
function InfoJet_OnPNGItemKeyDown(event, item) {
    //CID 0820 //2011.03.29 //Begin
    if (InfoJet_IsAncestorElementDisabled(item, "span")) {
        return;
    }
    //CID 0820 //2011.03.29 //End
    event = InfoJet_GetEvent(event);
    //CID 0249 //2009.03.15 //Begin
    if (event.keyCode == 46) {
        var img = InfoJet_GetElements(item)[0];
        InfoJet_OnPNGItemDelete(img);
    }
}
//CID 0828 //2011.03.10 //End

//CID 0656 //2010.10.22 //Begin
function InfoJet_OnPNGItemBlur(item) {
    item.style.backgroundColor = "";
    item.style.color = "#000000";
    var img = InfoJet_GetElements(item)[0];
    img.style.display = "none";
}
//CID 0656 //2010.10.22 //End

//CID 0656 //2010.10.23 //Begin
function InfoJet_OnPNGItemDelete(img) {
    //CID 0820 //2011.03.29 //Begin
    if (InfoJet_IsAncestorElementDisabled(img, "span")) {
        return;
    }
    //CID 0820 //2011.03.29 //End
    //CID 0828 //2011.03.10 //Begin
    InfoJet_FocusItemIndex = -1;
    var box = InfoJet_GetParent(InfoJet_GetParent(img));
    InfoJet_FocusControlId = box.id;
    //CID 0828 //2011.03.10 //End
    var xdocForm = document.getElementById("xdoc_form");
    var tr = InfoJet_GetParent(InfoJet_GetParent(InfoJet_GetParent(InfoJet_GetParent(img))));
    var contextIdHtml = "<input type=hidden id=xdoc_param_png_context_id name=xdoc_param_png_context_id />";
    InfoJet_InsertAdjacentHTMLBeforeEnd(xdocForm, contextIdHtml);
    //CID 0858 //2011.03.29 //Begin
    document.getElementById("xdoc_param_png_context_id").value = tr.id;
    //CID 0858 //2011.03.29 //End
    var accountIdHtml = "<input type=hidden id=xdoc_param_png_account_id name=xdoc_param_png_account_id />";
    InfoJet_InsertAdjacentHTMLBeforeEnd(xdocForm, accountIdHtml);
    document.getElementById("xdoc_param_png_account_id").value = img.getAttribute("acccountId");
    //CID 0914 //2011.05.20 //Begin
    var pngId = tr.getAttribute("pngId");
    var pngIdHtml = "<input type=hidden id=xdoc_param_png_id name=xdoc_param_png_id />";
    InfoJet_InsertAdjacentHTMLBeforeEnd(xdocForm, pngIdHtml);
    document.getElementById("xdoc_param_png_id").value = pngId;
    //CID 0914 //2011.05.20 //End    
    document.getElementById("xdoc_param_command").value = "Update_DeletePrincipal";
    InfoJet_MoveProgress2ControlPosition(tr);
    InfoJet_Submit();
    return false;
}
//CID 0656 //2010.10.23 //End

//CID 0657 //2010.12.14 //Begin
function InfoJet_OnEXIPickerClick(event, exiAddressButton) {
    //CID 0820 //2011.03.29 //Begin
    if (InfoJet_IsAncestorElementDisabled(exiAddressButton, "span")) {
        return;
    }
    //CID 0820 //2011.03.29 //End
    var tr = InfoJet_GetParent(InfoJet_GetParent(exiAddressButton));
    //CID 0858 //2011.03.29 //Begin
    
    //CID 0858 //2011.03.29 //End
    var exiId = tr.getAttribute("exiId");
    var multiItem = tr.getAttribute("multiItem");
    //CID 0748 //2010.12.29 //Begin
    var dialogTitle = tr.getAttribute("pickerDialogTitle");
    var xml = window.showModalDialog(InfoJet_WebContext + "js/exipicker_dialog.htm", new Array(window, exiId, multiItem, dialogTitle), 'dialogWidth:570px;dialogHeight:390px;resizable:yes;help:no;');
    //CID 0748 //2010.12.29 //End
    if (xml) {
        //CID 0828 //2011.03.10 //Begin
        InfoJet_FocusItemIndex = -1;
        var box = InfoJet_GetElements(InfoJet_GetElements(tr)[0])[0];
        InfoJet_FocusControlId = box.id;
        //CID 0828 //2011.03.10 //End
        var xdocForm = document.getElementById("xdoc_form");
        var xmlHtml = "<input type=hidden id=xdoc_param_exi_added_xml name=xdoc_param_exi_added_xml />";
        InfoJet_InsertAdjacentHTMLBeforeEnd(xdocForm, xmlHtml);
        document.getElementById("xdoc_param_exi_added_xml").value = xml;
        var contextIdHtml = "<input type=hidden id=xdoc_param_exi_context_id name=xdoc_param_exi_context_id />";
        InfoJet_InsertAdjacentHTMLBeforeEnd(xdocForm, contextIdHtml);
        //CID 0858 //2011.03.29 //Begin
        document.getElementById("xdoc_param_exi_context_id").value = tr.id;
        //CID 0858 //2011.03.29 //End
        var exiIdHtml = "<input type=hidden id=xdoc_param_exi_id name=xdoc_param_exi_id />";
        InfoJet_InsertAdjacentHTMLBeforeEnd(xdocForm, exiIdHtml);
        document.getElementById("xdoc_param_exi_id").value = exiId;
        document.getElementById("xdoc_param_command").value = "Update_AddEXIItems";
        InfoJet_MoveProgress2ControlPosition(tr);
        InfoJet_Submit();
    }
}
//CID 0657 //2010.12.15 //End

//CID 0657 //2010.12.14 //Begin
function InfoJet_ShowEXIItems(items) {
    if (InfoJet_CurrentDialog != null) {
        InfoJet_CurrentDialog.ShowItems(items);
    }
}
//CID 0657 //2010.12.14 //End

//CID 0657 //2010.12.09 //Begin
function InfoJet_OnEXIItemClick(item) {
    //CID 0820 //2011.03.29 //Begin
    if (InfoJet_IsAncestorElementDisabled(item, "span")) {
        return false;
    }
    //CID 0820 //2011.03.29 //End
    //CID 0754 //2011.01.18 //Begin
    var tr = InfoJet_GetParent(InfoJet_GetParent(InfoJet_GetParent(item)));
    var button = InfoJet_GetFirstChild(InfoJet_GetLastChild(tr));
    if (button.disabled) {
        return false;
    }
    //CID 0754 //2011.01.18 //End
    item.style.backgroundColor = "blue";
    item.style.color = "#FFFFFF";
    var img = InfoJet_GetElements(item)[0];
    img.style.display = "";
    return false;
}
//CID 0657 //2010.12.09 //End

//CID 0828 //2011.03.10 //Begin
function InfoJet_OnEXIItemKeyDown(event, item) {
    //CID 0820 //2011.03.29 //Begin
    if (InfoJet_IsAncestorElementDisabled(item, "span")) {
        return;
    }
    //CID 0820 //2011.03.29 //End
    event = InfoJet_GetEvent( event );
	//CID 0249 //2009.03.15 //Begin
    if (event.keyCode == 46) {
        var img = InfoJet_GetElements(item)[0];
        InfoJet_OnEXIItemDelete(img);
    }
}
//CID 0828 //2011.03.10 //End

//CID 0657 //2010.12.09 //Begin
function InfoJet_OnEXIItemBlur(item) {
    item.style.backgroundColor = "";
    item.style.color = "#000000";
    var img = InfoJet_GetElements(item)[0];
    img.style.display = "none";
}
//CID 0657 //2010.12.09 //End

//CID 0657 //2010.12.09 //Begin
function InfoJet_OnEXIItemDelete(img) {
    //CID 0820 //2011.03.29 //Begin
    if (InfoJet_IsAncestorElementDisabled(img, "span")) {
        return;
    }
    //CID 0820 //2011.03.29 //End
    //CID 0828 //2011.03.10 //Begin
    InfoJet_FocusItemIndex = -1;
    var box = InfoJet_GetParent(InfoJet_GetParent(img));
    InfoJet_FocusControlId = box.id;
    //CID 0828 //2011.03.10 //End
    var xdocForm = document.getElementById("xdoc_form");
    var tr = InfoJet_GetParent(InfoJet_GetParent(InfoJet_GetParent(InfoJet_GetParent(img))));
    var contextIdHtml = "<input type=hidden id=xdoc_param_exi_context_id name=xdoc_param_exi_context_id />";
    InfoJet_InsertAdjacentHTMLBeforeEnd(xdocForm, contextIdHtml);
    //CID 0858 //2011.03.29 //Begin
    document.getElementById("xdoc_param_exi_context_id").value = tr.id;
    //CID 0858 //2011.03.29 //End
    //CID 0750 //2010.12.30 //Begin
    var id1Html = "<input type=hidden id=xdoc_param_exi_entity_id1 name=xdoc_param_exi_entity_id1 />";
    InfoJet_InsertAdjacentHTMLBeforeEnd(xdocForm, id1Html);
    document.getElementById("xdoc_param_exi_entity_id1").value = img.getAttribute("entityId1");
    var id2Html = "<input type=hidden id=xdoc_param_exi_entity_id2 name=xdoc_param_exi_entity_id2 />";
    InfoJet_InsertAdjacentHTMLBeforeEnd(xdocForm, id2Html);
    document.getElementById("xdoc_param_exi_entity_id2").value = img.getAttribute("entityId2");
    var id3Html = "<input type=hidden id=xdoc_param_exi_entity_id3 name=xdoc_param_exi_entity_id3 />";
    InfoJet_InsertAdjacentHTMLBeforeEnd(xdocForm, id3Html);
    document.getElementById("xdoc_param_exi_entity_id3").value = img.getAttribute("entityId3");
    var id4Html = "<input type=hidden id=xdoc_param_exi_entity_id4 name=xdoc_param_exi_entity_id4 />";
    InfoJet_InsertAdjacentHTMLBeforeEnd(xdocForm, id4Html);
    document.getElementById("xdoc_param_exi_entity_id4").value = img.getAttribute("entityId4");
    var id5Html = "<input type=hidden id=xdoc_param_exi_entity_id5 name=xdoc_param_exi_entity_id5 />";
    InfoJet_InsertAdjacentHTMLBeforeEnd(xdocForm, id5Html);
    document.getElementById("xdoc_param_exi_entity_id5").value = img.getAttribute("entityId5");
    //CID 0750 //2010.12.30 //End
    document.getElementById("xdoc_param_command").value = "Update_DeleteEXIItem";
    InfoJet_MoveProgress2ControlPosition(tr);
    InfoJet_Submit();
    return false;
}
//CID 0657 //2010.12.09 //End

//CID 0800 //2011.03.15 //Begin
function InfoJet_OnDropdownListPickerClick(event, button) {
    var boxElement = InfoJet_GetParent(button);
    var dropdownListId = boxElement.getAttribute("dropdownListId");
    var selectElement = InfoJet_GetLastChild(boxElement);
    if (dropdownListId) {
        var xdocForm = document.getElementById("xdoc_form");
        var idParam = document.getElementById("xdoc_param_dropdownlist_id");
        if (idParam == null) {
            var idHtml = "<input type=hidden id=xdoc_param_dropdownlist_id name=xdoc_param_dropdownlist_id />";
            InfoJet_InsertAdjacentHTMLBeforeEnd(xdocForm, idHtml);
            idParam = document.getElementById("xdoc_param_dropdownlist_id");
        }
        idParam.value = dropdownListId;
        var contextIdParam = document.getElementById("xdoc_param_dropdownlist_context_id");
        if (contextIdParam == null) {
            var contextHtml = "<input type=hidden id=xdoc_param_dropdownlist_context_id name=xdoc_param_dropdownlist_context_id />";
            InfoJet_InsertAdjacentHTMLBeforeEnd(xdocForm, contextHtml);
            contextIdParam = document.getElementById("xdoc_param_dropdownlist_context_id");
        }
        contextIdParam.value = InfoJet_GetElementId(selectElement);
        var buttonIdParam = document.getElementById("xdoc_param_dropdownlist_button_id");
        if (buttonIdParam == null) {
            var buttonIdHtml = "<input type=hidden id=xdoc_param_dropdownlist_button_id name=xdoc_param_dropdownlist_button_id />";
            InfoJet_InsertAdjacentHTMLBeforeEnd(xdocForm, buttonIdHtml);
            buttonIdParam = document.getElementById("xdoc_param_dropdownlist_button_id");
        }
        buttonIdParam.value = button.id;
        document.getElementById("xdoc_param_command").value = "Update_LoadDropdownListItems";
        InfoJet_MoveProgress2ControlPosition(button);
        InfoJet_Submit();
    }
}
//CID 0800 //2011.03.15 //End

//CID 0800 //2011.03.15 //Begin
function InfoJet_PopupDropdownList(buttonId, selectHtml) {
    var button = document.getElementById(buttonId);
    var boxElement = InfoJet_GetParent(button);
    var popup = document.getElementById("xdoc_popup");
    if (popup == null) {
        var popupHtml = "<div id='xdoc_popup' style='width:0px;height:0px;position:absolute;z-index:99;background:#FFFFFF;padding:0px;margin:0px;'>" + selectHtml + "</div>";
        InfoJet_InsertAdjacentHTMLBeforeEnd(InfoJet_Container, popupHtml);
        popup = document.getElementById("xdoc_popup");
    }
    popup.innerHTML = selectHtml;
    var pos = InfoJet_GetPos(boxElement);
    popup.style.left = pos.left;
    popup.style.top = pos.top + boxElement.offsetHeight;
    popup.style.display = "";
    var select = InfoJet_GetFirstChild(popup);
    select.setAttribute("buttonId", buttonId);
    if (select.offsetWidth < boxElement.offsetWidth) {
        select.style.width = boxElement.offsetWidth;
    }
    select.focus();
}
//CID 0800 //2011.03.15 //End

//CID 0800 //2011.03.20 //Begin
function InfoJet_HidePopupDropdownList(select) {
    var popup = InfoJet_GetParent(select);
    popup.style.display = "none";
    popup.innerHTML = "";
    var buttonId = select.getAttribute("buttonId");
    var button = document.getElementById(buttonId);
    button.focus();
}
//CID 0800 //2011.03.20 //End

//CID 0800 //2011.03.20 //Begin
function InfoJet_UpdatePopupDropdownList(select) {
    var selectedValue = "";
    var selectedName = "";
    if (select.selectedIndex >= 0) {
        var selectedOption = select.options[select.selectedIndex];
        selectedValue = selectedOption.value;
        selectedName = selectedOption.text;
    }
    var buttonId = select.getAttribute("buttonId");
    var button = document.getElementById(buttonId);
    var boxElement = InfoJet_GetParent(button);
    var spanElement = InfoJet_GetFirstChild(boxElement);
    spanElement.innerHTML = selectedName;
    var selectElement = InfoJet_GetLastChild(boxElement);
    var length = selectElement.options.length;
    for (var i = 0; i < length;  i ++) {
        selectElement.options.remove(0);
    }
    var option = new Option(selectedName, selectedValue);
    selectElement.options.add(option);
    selectElement.selectedIndex = 0;
    InfoJet_OnControlChange(null, selectElement);
}
//CID 0800 //2011.03.20 //End

//CID 0800 //2011.03.20 //Begin
function InfoJet_OnPopupDropdownListBlur(select) {
    InfoJet_HidePopupDropdownList(select);
}
//CID 0800 //2011.03.20 //End

//CID 0800 //2011.03.20 //Begin
function InfoJet_OnPopupDropdownListKeyPress(event, select) {
    if (event.keyCode == 27) {
        InfoJet_HidePopupDropdownList(select);
    } else if (event.keyCode == 13) {
        InfoJet_UpdatePopupDropdownList(select);
        InfoJet_HidePopupDropdownList(select);
    }
}
//CID 0800 //2011.03.20 //End

//CID 0800 //2011.03.20 //Begin
function InfoJet_OnPopupDropdownListClick(event, select) {
    InfoJet_UpdatePopupDropdownList(select);
    InfoJet_HidePopupDropdownList(select);
}
//CID 0800 //2011.03.20 //End

function InfoJet_OnMenuClick( event , menu ){
	if( menu.getAttribute( "type" ) == "group" ){
		return;
	}
	InfoJet_HiddenAllGroupMenu();
	var menuArrow = document.getElementById( "xdoc_menu_focus_arrow" );
	menuArrow.style.display = "none";
	
	var action = menu.getAttribute( "action" );
	var component = menu.getAttribute( "component" );
	if( action != null ){
		if( action == "switchView" ){
			var viewId = menu.getAttribute( "component" );
			InfoJet_DoSwitchView( viewId );
		}else if( action == "noErrorFormatting" ){
			InfoJet_CheckErrorFormatting( menu );
		}else if( action == "printableVersion" ){
			InfoJet_OpenPrintableVersion( null );
		}else if( action == "attach" && component == "xFileAttachment" ){
			var itemId = menuArrow.getAttribute( "itemId" );
			var fileLink = document.getElementById( itemId );
			InfoJet_AttachFile( fileLink );
			InfoJet_OnFocus( event, fileLink, "control" );
		}else if( action == "open" && component == "xFileAttachment" ){
			var itemId = menuArrow.getAttribute( "itemId" );
			var fileLink = document.getElementById( itemId );
			if( fileLink.href == null ){
				//try again for duplicate binding.
				fileLink = document.getElementById( itemId + ",1" );
			}
			if( fileLink != null ){
				//CID 0022 //2008.06.23 //Begin
				var href = fileLink.href;
				if( href == "javascript:void(0)" ){
					//CID 0029 //2009.10.13 //Begin
					href = fileLink.getAttribute( "fileHref" );
					//CID 0029 //2009.10.13 //End
				}
				//CID 0023 //2008.06.19 //if
				if( href != null && href != "javascript:void(0)" ){                           
					window.open( href);
				}
				//CID 0022 //2008.06.23 //End
			}
		}else if( action == "saveAs" && component == "xFileAttachment" ){
			var itemId = menuArrow.getAttribute( "itemId" );
			var fileLink = document.getElementById( itemId );
			if( fileLink.href == null ){
				//try again for duplicate binding.
				fileLink = document.getElementById( itemId + ",1" );
			}
			if( fileLink != null ){
				//CID 0023 //2008.06.19 //Begin
				//CID 0022 //2008.06.23 //Begin
				var href = fileLink.href;
				if( href == "javascript:void(0)" ){
					//CID 0029 //2009.10.13 //Begin
					href = fileLink.getAttribute( "fileHref" );
					//CID 0029 //2009.10.13 //End
				}
				if( href != null && href != "javascript:void(0)" ){
				//CID 0022 //2008.06.23 //End
					if( InfoJet_SaveAsPage != null ){
						//CID 0022 //2008.06.23 //href
						window.open( InfoJet_SaveAsPage + "?file=" + href );                   
					}else{
					//CID 0023 //2008.06.19 //End
						//CID 0022 //2008.06.23 //href
						InfoJet_SaveAsWindow = window.open( href );                            
						try{
							//CID 0009 //2008.06.04 //Begin
							if( InfoJet_IsImage( href ) ){                                     
								//CID 0009 //2008.06.03 //Begin
								//CID 0022 //2008.06.23 //href
								window.setTimeout( "if( InfoJet_SaveAsWindow != null ){ InfoJet_SaveAsWindow.document.execCommand( 'SaveAs' ); }", 1000 );
								//CID 0009 //2008.06.03 //End
							}else{
								InfoJet_SaveAsWindow.document.execCommand( 'SaveAs' );
							}
							//CID 0009 //2008.06.04 //End
						}catch(e){}
					}
				}
			}
		}else if( action == "remove" && component == "xFileAttachment" ){
			var itemId = menuArrow.getAttribute( "itemId" );
			var fileLink = document.getElementById( itemId );
			if( fileLink.href == null ){
				//try again for duplicate binding.
				fileLink = document.getElementById( itemId + ",1" );
			}
			if( fileLink != null ){
				InfoJet_RemoveFile( fileLink );
				InfoJet_OnFocus( event, fileLink, "control" );
			}
		}else{
			var itemId = menuArrow.getAttribute( "itemId" );
			var xmlToEditName = menu.getAttribute( "xmlToEdit" );
			var xmlToEditAction = menu.getAttribute( "component" ) + "::" + menu.getAttribute( "action" );
			InfoJet_DoXmlToEditAction( itemId , xmlToEditName , xmlToEditAction );		
		}
	}
}

//CID 0009 //2008.06.04 //Begin
function InfoJet_IsImage( href ){
	var slashIndex = href.lastIndexOf('.');
	if( (slashIndex > 0) && (slashIndex < href.length -1) ){
		var fileExt = href.substr( slashIndex + 1 ).toLowerCase();
		if( fileExt == "gif" || fileExt == "jpg" || fileExt == "bmp" || fileExt == "emf" || fileExt == "exif" || fileExt == "icon" || fileExt == "png" || fileExt == "tiff" || fileExt == "wmf" ){
			return true;
		}
	}
	return false;
}
//CID 0009 //2008.06.04 //Begin

function InfoJet_OnMenuArrowPoint( event , source , type ){
	event = InfoJet_GetEvent( event );
	if( type == "arrow" ){
		var menuArrow = document.getElementById( "xdoc_menu_focus_arrow" );
		source = document.getElementById( menuArrow.getAttribute( "itemId" ) );
	}
	return InfoJet_ShowContextMenu( event , source , type );
}

function InfoJet_OnContextMenu( event , source ){
	if( !InfoJet_ReplaceBrowserContextMenu ){
		event.cancelBubble = true;
		event.returnValue = true;
		return true;
	}
	
	InfoJet_HiddenAllGroupMenu();
	if( source.disabled ){
		//如果事件源被disabled了,使用默认ContextMenu.
		event.cancelBubble = true;
		event.returnValue = true;
		return true;
	}
	event = InfoJet_GetEvent( event );
	var tagName = source.tagName.toLowerCase();
	if (tagName != "div" && tagName != "table" && tagName != "tr" && tagName != "td") {
        //CID 1426 //2012.11.02 //Begin
		//var xctname = source.getAttribute( InfoJet_XdPrefix + "xctname" );
		//if( !(xctname != null && xctname == "FileAttachment") ){
		var isFileAttachment = source.getAttribute("isFileAttachment");
        if(isFileAttachment != "true"){
        //CID 1426 //2012.11.02 //End
        	//文本框,图片,Link使用默认ContextMenu.
			event.cancelBubble = true;
			event.returnValue = true;
			return true;
		}
	}
	InfoJet_OnFocus( event , source , "common" );
	return InfoJet_ShowContextMenu( event , source , "arrow" );		
}

function InfoJet_ShowContextMenu( event , source , type ){
	var itemElement = InfoJet_RefreshXmlToEditItem( source , true );
	var itemId = "";
	if( itemElement != null ){
		itemId = itemElement.id;
	}
	var contextIds = new Array();
	if( type == "arrow" ){
		InfoJet_GetMenuContextIds( contextIds , source );
	}else if( type == "point" ){
		contextIds[ contextIds.length ] = document.getElementById( "xdoc_data_root_element_id" ).innerHTML;
	}
	if( contextIds.length >= 1 ){
		InfoJet_HiddenAllGroupMenu();
		var menuCount = InfoJet_ShowMenuByContext( "" , contextIds , itemId, type );
		var xdocMenu = document.getElementById( "xdoc_menu" );
		if( menuCount > 0 ){
			var viewId = document.getElementById( "xdoc_param_view_id" ).value;
			var xdocMenu = document.getElementById( "xdoc.contextmenu.group" + viewId );
			var left = event.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
			var top = event.clientY + document.body.scrollTop + document.documentElement.scrollTop;
			xdocMenu.style.left = left;
			xdocMenu.style.top = top;
			xdocMenu.style.display = "block";
			InfoJet_HideSelects( xdocMenu, left, top );
			event.cancelBubble = true;
			event.returnValue = false;
		}
		return false;
	}else{
		return true;
	}
}

function InfoJet_HideSelects( xdocMenu, left, top ){
	if( InfoJet_IsIE7() ){ //CID 0515 //2010.03.24 //IsIE7
		return;
	}
	
	InfoJet_Selects = new Array();

	var menuX1 = left;
	var menuY1 = top;
	var menuX2 = left + xdocMenu.offsetWidth;
	var menuY2 = top + xdocMenu.offsetHeight;
	
	var selects = document.getElementsByTagName("select");
	for (var i = 0; i < selects.length; i ++) {
		var select = selects[i];
		
		var pos = InfoJet_GetPos( select );
		//CID 0501 //2010.01.23 //Begin
		if( pos == null ){
			return;
		}
		//CID 0501 //2010.01.23 //End
		var selectX1 = pos.left;
		var selectY1 = pos.top;
		var selectX2 = pos.left + select.offsetWidth;
		var selectY2 = pos.top + select.offsetHeight;
		
		if( !((menuX1 > selectX2) || (selectX1 > menuX2) || (menuY1 > selectY2) || (selectY1 > menuY2)) ){
			var visibility = select.style.visibility;
			if (!visibility) {
				visibility = select.currentStyle.visibility;
			}
			select.setAttribute( "InfoJet_Visibility", visibility );
			select.style.visibility = "hidden";
			InfoJet_Selects[ InfoJet_Selects.length ] = select;
		}
	}
}

function InfoJet_ShowSelects(){
	if( InfoJet_IsIE7() ){ //CID 0515 //2010.03.24 //IsIE7
		return;
	}
	
	if( InfoJet_Selects != null ){
		for( var i = 0; i < InfoJet_Selects.length; i ++ ){
			var select = InfoJet_Selects[ i ];
			select.style.visibility = select.getAttribute( "InfoJet_Visibility" );
		}
	}
	InfoJet_Selects = null;
}

function InfoJet_GetMenuContextIds( contextIds , source ){
	if( source == null || source.id == "xdoc_view" ){
		return;
	}
	var id = InfoJet_GetElementId( source );
	if( id != null && id.indexOf( "_0_" ) == 0 ){
		contextIds[ contextIds.length ] = id;
	}
	InfoJet_GetMenuContextIds( contextIds , InfoJet_GetParent( source ) );
}

function InfoJet_ShowMenuByContext( baseId , contextIds , itemId, type ){
	var viewId = document.getElementById( "xdoc_param_view_id" ).value;
	var menuCount = 0;
	var parentStyles = InfoJet_GetParentStyles( InfoJet_ItemElement );
	for( var i = 0 ; true ; i ++ ){
		var id = baseId + i;
		var menuId = id + ".menu" + viewId;
		var menu = document.getElementById( menuId );
		if( menu != null ){
			var action = menu.getAttribute( "action" );
			var isSeparator = ( action != null ) && ( action == "none" );
			var isSwitchView = ( action != null ) && ( action == "switchView" );
			var isPrintableVersion = ( action != null ) && ( action == "printableVersion" );
			var isNoErrorFormatting = ( action != null ) && ( action == "noErrorFormatting" );
			if( isSeparator && menuCount > 0 ){
				menu.style.display = "block";
			}else if( InfoJet_IsShowMenu( menu , contextIds, itemId, parentStyles ) ){ //CID 0285 //2009.05.12 //parentStyles
				menu.style.display = "block";
				menuCount ++;
				//CID 0285 //2009.05.12 //Comment
				/*
				var groupId = id + ".group" + viewId;
				if( document.getElementById( groupId ) != null ){
					var subMenuCount = InfoJet_ShowMenuByContext( id + "." , contextIds, itemId, type );
					if( subMenuCount <= 0 ){
						menu.style.display = "none";
						menuCount --
					}
				}
				*/
			}else if( isSwitchView || isPrintableVersion || isNoErrorFormatting ){
				menu.style.display = "block";
				menuCount ++;
			}else{
				menu.style.display = "none";
			}
		}else{
			break;
		}
	}
	return menuCount;
}

//CID 0285 //2009.05.12 //Begin
function InfoJet_GetParentStyles( element ){
	var styles = new Array();
	var parent = InfoJet_GetParent(element);
	while( parent != null ){
		var style = parent.style.cssText;
		if( style != null && style.length > 0 )
		{
			styles.push( style );
		}
		parent = InfoJet_GetParent(parent);
		if( parent != null && parent.id == "xdoc_view" ){
			break;
		}
	}
	return styles;
}
//CID 0285 //2009.05.12 //End

function InfoJet_IsShowMenu( menu , contextIds, itemId, parentStyles ){
	if( menu.getAttribute( "type" ) == "group" ){
		return true;
	}
	var contextId = contextIds[ 0 ];
	var xmlToEdit = menu.getAttribute( "xmlToEdit" );
	var component = menu.getAttribute( "component" );
	//CID 0108 //2008.09.01 //Begin
	var xmlToEditDisabled = component + "-" + xmlToEdit + "-editing: disabled"
	//CID 0285 //2009.05.12 //Begin
	for( var i = 0; i < parentStyles.length; i ++ ){
		var parentStyle = parentStyles[ i ];
		if( parentStyle.indexOf( xmlToEditDisabled ) > 0 )
		{
			return false;
		}
	}
	//CID 0285 //2009.05.12 //End
	//CID 0108 //2008.09.01 //End
	var action = menu.getAttribute( "action" );
	if( component == "xReplace" ){
		if( action == "replace" ){
			var containerIdArray = document.getElementById( xmlToEdit + "_container" ).innerHTML;
			if( InfoJet_IsArrayIdInContextIds( containerIdArray , contextIds ) &&
				InfoJet_IsIdInArray( contextId , xmlToEdit + "_item" ) ){
				return true;
			}else{
				return false;
			}
		}
	}else if( component == "xOptional" ){
		if( action == "insert" ){
			if( InfoJet_IsIdInArray( contextId , xmlToEdit + "_container"  ) &&
				InfoJet_IdArrayIdCount( xmlToEdit + "_item" ) <= 0 ){
				return true;
			}else{
				return false;
			}
		}else if( action == "remove" ){
			var containerIdArray = document.getElementById( xmlToEdit + "_container" ).innerHTML;
			if( InfoJet_IsArrayIdInContextIds( containerIdArray , contextIds ) &&
				InfoJet_IsIdInArray( contextId , xmlToEdit + "_item" ) ){
				return true;
			}else{
				return false;
			}
		}
	}else if( component == "xCollection" ){
		if( action == "insert" ){
			if( InfoJet_IsIdInArray( contextId , xmlToEdit + "_container"  ) ){
				return true;
			}else{
				return false;
			}
		}else if( action == "insertBefore" ){
			var containerIdArray = document.getElementById( xmlToEdit + "_container" ).innerHTML;
			if( InfoJet_IsArrayIdInContextIds( containerIdArray , contextIds ) &&
				InfoJet_IsIdInArray( contextId , xmlToEdit + "_item" ) ){
				return true;
			}else{
				return false;
			}
		}else if( action == "insertAfter" ){
			var containerIdArray = document.getElementById( xmlToEdit + "_container" ).innerHTML;
			if( InfoJet_IsArrayIdInContextIds( containerIdArray , contextIds ) &&
				InfoJet_IsIdInArray( contextId , xmlToEdit + "_item" ) ){
				return true;
			}else{
				return false;
			}
		}else if( action == "remove" ){
			var containerIdArray = document.getElementById( xmlToEdit + "_container" ).innerHTML;
			if( InfoJet_IsArrayIdInContextIds( containerIdArray , contextIds ) &&
				InfoJet_IsIdInArray( contextId , xmlToEdit + "_item" ) ){
				return true;
			}else{
				return false;
			}
		}else if( action == "removeAll" ){
			if( InfoJet_IsIdInArray( contextId , xmlToEdit + "_container"  ) && 
				InfoJet_IdArrayIdCount( xmlToEdit + "_item" ) > 0 ){
				return true;
			}else{
				return false;
			}		
		}
    } else if (component == "xFileAttachment") {
        itemId = InfoJet_GetPureId( itemId );
        if (InfoJet_IsIdInArray(itemId, xmlToEdit + "_item")) {
            //CID 1447 //2012.11.10 //Begin
            if (InfoJet_EnablePlaceholderUI) {
                if (action == "attach" || action == "remove") {
                    var itemElement = document.getElementById(itemId);
                    var disableEditing = itemElement.getAttribute(InfoJet_XdPrefix + "disableEditing");
                    if (disableEditing != null && disableEditing.toLowerCase() == "yes") {
                        return false;
                    }
                    if (itemElement.disabled) {
                        return false;
                    }
                }
            } else {
                //CID 0002 //2008.05.29 //Begin
                var fileAttachmentSpan = InfoJet_GetParent(document.getElementById(itemId));
                //CID 0007 //2008.06.10 //Begin
                if (fileAttachmentSpan == null || fileAttachmentSpan.getAttribute(InfoJet_XdPrefix + "disableEditing") == null) {
                    fileAttachmentSpan = InfoJet_GetParent(document.getElementById(itemId + ",1"));
                }
                //CID 0007 //2008.06.10 //End
                if (fileAttachmentSpan != null) {
                    var disableEditing = fileAttachmentSpan.getAttribute(InfoJet_XdPrefix + "disableEditing");
                    if (disableEditing != null && disableEditing.toLowerCase() == "yes") {
                        if (action == "attach" || action == "remove") {
                            return false;
                        }
                    }
                }
                //CID 0002 //2008.05.29 //End
            }
            //CID 1447 //2012.11.10 //End
			return true;
		}else{
			return false;
		}
	}
	return false;
}

function InfoJet_IsArrayIdInContextIds( idArray , contextIds ){
	var ids = idArray.split( ";" );
	for( var i = 0 ; i < ids.length ; i ++ ){
		var id = ids[ i ];
		for( var c = 0 ; c < contextIds.length ; c ++ ){
			var contextId = contextIds[ c ];
			if( id == contextId ){
				return true;
			}
		}
	}
	return false;
}

function InfoJet_IdArrayIdCount( idArrayName ){
	var idArray = document.getElementById( idArrayName ).innerHTML;
	if( idArray.length <= 0 ){
		return 0;
	}else{
		if( idArray.indexOf( ";" ) ){
			return 1;
		}else{
			var ids = idArray.split( ";" );
			return ids.length;	
		}
	}
}


function InfoJet_OnClick( event , source , type ){
	InfoJet_HiddenAllGroupMenu();
	InfoJet_HideBorder( "xdoc_item_focus" );
	if( !InfoJet_BrowserQuick ){
		InfoJet_HideBorder( "xdoc_field_focus" );
	}
	event = InfoJet_GetEvent( event );
	//CID 0086 //2008.08.14 //Begin
	InfoJet_OnFocus( event , source , type, true );
	//CID 0086 //2008.08.14 //End
	
	//CID 0236 //2009.03.03 //Begin
	//CID 0546 //2010.05.11 //Info
	var multiSelectListBoxXmlToEditInfo = InfoJet_GetMultiSelectListItemXmlToEditInfo( source );
	if( multiSelectListBoxXmlToEditInfo != null && 
		multiSelectListBoxXmlToEditInfo.xmlToEdit != null && multiSelectListBoxXmlToEditInfo.xmlToEdit.length > 0 &&
		multiSelectListBoxXmlToEditInfo.contextId != null && multiSelectListBoxXmlToEditInfo.contextId.length > 0) {
	    //CID 0660 //2010.09.15 //Begin
	    InfoJet_MoveProgress2ControlPosition(source);
	    //CID 0660 //2010.09.15 //End
		//CID 0332 //2009.08.08 //Begin
		InfoJet_OldValueState.boolValue = !source.checked;
		InfoJet_OldValueState.valid = true;
		//CID 0332 //2009.08.08 //End
		InfoJet_RefreshContext( source );
		document.getElementById( "xdoc_param_xml_to_edit_name" ).value = multiSelectListBoxXmlToEditInfo.xmlToEdit;
		var xdocForm = document.getElementById( "xdoc_form" );
		var itemValueHtml = "<input type=hidden id=xdoc_param_multi_select_list_item_value name=xdoc_param_multi_select_list_item_value>";
		InfoJet_InsertAdjacentHTMLBeforeEnd( xdocForm, itemValueHtml );
		var onValue = source.getAttribute( InfoJet_XdPrefix + "onValue" );
		document.getElementById( "xdoc_param_multi_select_list_item_value" ).value = onValue;
		//CID 0546 //2010.05.11 //Begin
		var contextIdHtml = "<input type=hidden id=xdoc_param_multi_select_list_context_id name=xdoc_param_multi_select_list_context_id>";
		InfoJet_InsertAdjacentHTMLBeforeEnd( xdocForm, contextIdHtml );
		document.getElementById( "xdoc_param_multi_select_list_context_id" ).value = multiSelectListBoxXmlToEditInfo.contextId;
		//CID 0546 //2010.05.11 //End
		if( source.checked ){
			document.getElementById( "xdoc_param_xml_to_edit_action" ).value = "xTextList::newItem";
		}else{
			document.getElementById( "xdoc_param_xml_to_edit_action" ).value = "xTextList::deleteItem";
		}
		document.getElementById( "xdoc_param_command" ).value = "Update_XmlToEdit";
		InfoJet_Submit();
	}
	//CID 0236 //2009.03.03 //End
	else{
		//CID 0131 //2008.10.03 //Begin
		//CID 0343 //2009.06.24 //_s_
		if( type != null && type == "control" && source.id != null &&
			( source.id.indexOf( "_0_" ) == 0 || source.id.indexOf( "_s_" ) == 0 ) && InfoJet_IsButtonTypeInput( source ) ){
			InfoJet_OnControlChange( event, source );
		}
		//CID 0131 //2008.10.03 //End
	}
}

//CID 0236 //2009.03.03 //Begin
function InfoJet_GetMultiSelectListItemXmlToEditInfo( control ){
	var tagName = control.tagName.toLowerCase();
	if( tagName == "input" ){
		var type = control.getAttribute( "type" );
		if( type != null ){
			type = type.toLowerCase();
			if( type == "checkbox" ){
				var parentElement = InfoJet_GetParent( control );
				if( parentElement.className == "xdMultiSelectListItem" ){
					var ancestorElement = InfoJet_GetParent( parentElement );
					var info = {xmlToEdit:"" , contextId:""};
					info.xmlToEdit = ancestorElement.getAttribute("xmlToEdit");
					info.contextId = ancestorElement.getAttribute("contextId");
					return info;
				}
			}
		}
	}
	return null;
}
//CID 0236 //2009.03.03 //End

//CID 0131 //2008.10.03 //Begin
function InfoJet_IsButtonTypeInput( control ){
	var tagName = control.tagName.toLowerCase();
	if( tagName == "input" ){
		var type = control.getAttribute( "type" );
		if( type != null ){
			type = type.toLowerCase();
			if( type == "checkbox" || type == "radio" ){
				return true;
			}
		}
	}
	return false;
}
//CID 0131 //2008.10.03 //End

function InfoJet_HiddenAllGroupMenu(){
	InfoJet_ShowSelects();
	if( InfoJet_IsInited() ){
		var viewId = document.getElementById( "xdoc_param_view_id" ).value;
		//CID 0284 //2009.05.10 //Begin
		var menu = document.getElementById( "xdoc.contextmenu.group" + viewId );
		//CID 0284 //2009.05.10 //End
		if( menu != null ){
			menu.style.display = "none";
		}
	}
	return true;
}

function InfoJet_HiddenGroupMenu( baseId ){
	var viewId = document.getElementById( "xdoc_param_view_id" ).value;
	for( var i = 0 ; true ; i ++ ){
		var id = baseId + i;
		var itemMenuId = id + ".menu" + viewId;
		var itemMenu = document.getElementById( itemMenuId )
		if( itemMenu != null ){
			itemMenu.style.backgroundColor = "#FFFFFF";
			itemMenu.style.borderColor = "#FFFFFF";
			var groupId = id + ".group" + viewId;
			if( document.getElementById( groupId ) != null ){
				document.getElementById( groupId ).style.display = "none";
				InfoJet_HiddenGroupMenu( id + "." );
			}
		}else{
			break;
		}
	}
}

function InfoJet_MenuOver( event , itemMenu ){
	itemMenu.style.backgroundColor = "#C1D2EE";
	itemMenu.style.borderColor = "#316AC5";
	//CID 0286 //2009.05.10 //Begin
	//InfoJet_HiddenSiblingSubMenu( itemMenu );
	//InfoJet_ShowSubMenuById( itemMenu.id );
	//CID 0286 //2009.05.10 //End
}

function InfoJet_MenuOut( event , itemMenu ){
	itemMenu.style.backgroundColor = "#FFFFFF";
	itemMenu.style.borderColor = "#FFFFFF";
}

function InfoJet_HiddenSiblingSubMenu( itemMenu ){
	var viewId = document.getElementById( "xdoc_param_view_id" ).value;
	var coords = itemMenu.id.split( "." );
	var id = "";
	for( var i = 0 ; i < coords.length - 2 ; i ++ ){
		id += coords[ i ] + ".";
	}
	var siblingId = "";
	for( var i = 0 ; true ; i ++ ){
		siblingId = id + i + ".menu" + viewId;
		if( document.getElementById( siblingId ) == null ){
			break;
		}else{
			if( siblingId != itemMenu.id ){
				InfoJet_HiddenSubMenuById( siblingId );
			}
		}
	}
}

function InfoJet_HiddenSubMenuById( itemMenuId ){
	var viewId = document.getElementById( "xdoc_param_view_id" ).value;
	var id = itemMenuId.substr( 0 , itemMenuId.length - 4 - viewId.length );
	var groupMenuId = id + "group" + viewId;
	if( document.getElementById( groupMenuId ) != null ){
		document.getElementById( groupMenuId ).style.display = "none";
		for( var i = 0 ; true ; i ++ ){
			var subMenuId = id + i + ".menu" + viewId;
			if( document.getElementById( subMenuId ) != null ){
				InfoJet_HiddenSubMenuById( subMenuId );
			}else{
				break;
			}
		}
	}
}

function InfoJet_ShowSubMenuById( itemMenuId ){
	var viewId = document.getElementById( "xdoc_param_view_id" ).value;
	var itemMenu = document.getElementById( itemMenuId );
	var groupMenuId = itemMenuId.substr( 0 , itemMenuId.length - 4 - viewId.length ) + "group" + viewId;
	var subMenu = document.getElementById( groupMenuId );
	if( subMenu != null ){
		var pos = InfoJet_GetPos( itemMenu );
		//CID 0501 //2010.01.23 //Begin
		if( pos == null ){
			return;
		}
		//CID 0501 //2010.01.23 //End
		subMenu.style.display = "block";
		if( InfoJet_IsIE() ){
			subMenu.style.left = pos.left + itemMenu.offsetWidth;
			subMenu.style.top = pos.top - 2;
		}else{
			subMenu.style.left = pos.left + itemMenu.offsetWidth + 4;
			subMenu.style.top = pos.top;
		}
	}
}

function InfoJet_ResetSwitchViewMenuCheck(){
	var viewId = document.getElementById( "xdoc_param_view_id" ).value;
	for( var i = 0 ; true ; i ++ ){
		var menuId = i + ".menu" + viewId;
		var menu = document.getElementById( menuId );
		if( menu != null ){
			var component = menu.getAttribute( "component" );
			if( component != null && component.length > 0 ){
				var checkId = i + ".check" + viewId;
				var check = document.getElementById( checkId );
				if( component == viewId ){
					check.innerHTML = "<div align='center'><img src='" + InfoJet_WebContext + "images/infojet_menu_check.gif'></img></div>"
				}else{
					check.innerHTML = "";
				}
			}
		}else{
			break;
		}
	}
}

function InfoJet_CheckErrorFormatting( menu ){
	InfoJet_NoErrorFormatting = !InfoJet_NoErrorFormatting;
	
	var checkId = menu.id.replace( "menu" , "check" );
	var check = document.getElementById( checkId );
	if( check != null ){
		if( InfoJet_NoErrorFormatting ){
			check.innerHTML = "<div align='center'><img src='" + InfoJet_WebContext + "images/infojet_menu_check.gif'></img></div>";
			InfoJet_HideAllErrors();
		}else{
			check.innerHTML = "";
			InfoJet_ShowAllErrors();
		}
	}
}

//CID 0291 //2009.05.31 //Begin
function InfoJet_IsFocusableControl( source ){
	//CID 0400 //2009.11.23 //Begin
	try{
		if( source.style.display == "none" || control.disabled || control.readOnly ){
			return false;
		}
	}catch(e){}
	//CID 0400 //2009.11.23 //End
	if( source.tagName != null ){
		var tagName = source.tagName.toLowerCase();
		if( tagName == "input" && source.getAttribute("type") != "hidden" ){
			return true;
		}
		if( tagName == "select" || tagName == "textarea" || tagName == "a" || tagName == "button" ){
			return true;
        }
        //CID 1198 //2012.05.26 //Begin
        if (tagName == "span") {
            return true;
        }
        //CID 1198 //2012.05.26 //End
	}
	return false;
}
//CID 0291 //2009.05.31 //End

//CID 0311 //2009.06.16 //Begin
function InfoJet_IsReadyForFocus( control ){
	if( control.disabled || control.readOnly ){
		return false;
	}else{
		return true;
	}
}
//CID 0311 //2009.06.16 //End

//CID 0311 //2009.06.16 //Begin
function InfoJet_FindFocusableControlInElement( element ){
	//CID 0400 //2009.09.22 //Begin
	try{
		if( element.style.display == "none" ){
			return null;
		}
	}catch(e){}
	//CID 0400 //2009.09.22 //End
	if( InfoJet_IsFocusableControl( element ) ){
		if( InfoJet_IsReadyForFocus( element ) ){
			return element;
		}
	}
	for( var i = 0; i < element.childNodes.length; i ++ ){
		var childNode = element.childNodes[ i ];
		if( InfoJet_IsFocusableControl( childNode ) ){
			if( InfoJet_IsReadyForFocus( childNode ) ){
				return childNode;
			}
		}
		var found = InfoJet_FindFocusableControlInElement( childNode );
		if( found != null ){
			return found;
		}
	}
	return null;
}
//CID 0311 //2009.06.16 //End

//CID 0311 //2009.06.16 //Begin
function InfoJet_FindNextFocusableControl( source ){
	var parent = InfoJet_GetParent( source );
	var current = source;
	var bindingDeep = 0;
	while( parent != null && parent.id != "xdoc_view" ){
		if( bindingDeep > 2 ){
			break;
		}
		var nextElement = InfoJet_GetNextElement( current );
		while( nextElement != null ){
			var found = InfoJet_FindFocusableControlInElement( nextElement );
			if( found != null ){
				return found;
			}
			nextElement = InfoJet_GetNextElement( nextElement );
		}
		if( parent.id != null && parent.id.indexOf( "_0_" ) == 0 ){
			bindingDeep ++;
		}
		current = parent;
		parent = InfoJet_GetParent( parent );
	}
	return null;
}
//CID 0311 //2009.06.16 //End

//CID 0347 //2009.07.13 //Begin
function InfoJet_OnButtonMouseDown( event, source ){
	source.setAttribute( "isMouseDown", "true" );
}
//CID 0347 //2009.07.13 //End

//CID 0332 //2009.08.07 //Begin
function InfoJet_RecordOldValueState( control ){
    if (InfoJet_OldValueState == null) {
        //CID 0387 //2010.11.26 //hasField
        InfoJet_OldValueState = { controlId:null, textValue:null, boolValue:false, selectedIndex:-1, fieldId:null, fieldValue:null, valid:false, hasField:false };
    }
    InfoJet_OldValueState.valid = false;
    InfoJet_OldValueState.controlId = control.id;
    //CID 0408 //2009.09.29 //Begin
    var tagName = null;
    try{
		tagName = control.tagName.toLowerCase();
	}catch(e){
		return;
	}
    //CID 0408 //2009.09.29 //End
    if( tagName == "select" ){
		InfoJet_OldValueState.selectedIndex = control.selectedIndex;
		if( InfoJet_IsComboBoxControl( control ) ){
			var textField = InfoJet_GetPreviousElement( control );
			InfoJet_OldValueState.textValue = textField.value;
		}
    }else if( tagName == "input" ){
        var type = control.type.toLowerCase();
        if( type == "text" || type == "password" ){
            InfoJet_OldValueState.textValue = control.value;
            if( InfoJet_IsComboBoxControl( control ) ){
				var select = InfoJet_GetNextElement( control );
				InfoJet_OldValueState.selectedIndex = select.selectedIndex;
            }
        }else if( type == "checkbox" ){
            //Undo with the xml field value.
            var parentElement = InfoJet_GetParent( control );
			if( parentElement.className == "xdMultiSelectListItem" ){
				if( control.id.length <= 0 ){
					control.id = "MCheckBox" + (new Date()).getTime();
					InfoJet_OldValueState.controlId = control.id;
				}
			}
        }else if( type == "radio" ){
			//Undo with the xml field value.
        }else{
            InfoJet_OldValueState.controlId = null;
        }
    }else if( tagName == "textarea" ){
        InfoJet_OldValueState.textValue = control.value;
    } else if (InfoJet_IsRichTextBox(control)) {
        //CID 1338 //2012.09.18 //Begin
        InfoJet_OldValueState.textValue = "to be filled later";
        //CID 1338 //2012.09.18 //End
    }else{
        InfoJet_OldValueState.controlId = null;
    }
    if( InfoJet_OldValueState.controlId != null ){
        InfoJet_OldValueState.fieldId = "xdoc" + InfoJet_GetElementId( control );
        var xmlField = document.getElementById( InfoJet_OldValueState.fieldId );
        if( xmlField == null ){
            InfoJet_OldValueState.fieldValue = null;
			//CID 0387 //2010.11.26 //Begin
            InfoJet_OldValueState.hasField = false;
            //CID 0387 //2010.11.26 //End
        }else{
            InfoJet_OldValueState.fieldValue = xmlField.value;
            //CID 0387 //2010.11.26 //Begin
            InfoJet_OldValueState.hasField = true;
            //CID 0387 //2010.11.26 //End
        }
    }
}
//CID 0332 //2009.08.07 //End

//CID 0332 //2009.08.07 //Begin
function InfoJet_CheckOldValueState( control ){
	if( InfoJet_OldValueState != null ){
        if( InfoJet_OldValueState.controlId != null && InfoJet_OldValueState.controlId == control.id ){
            InfoJet_OldValueState.valid = true;
        }else{
            InfoJet_OldValueState.valid = false;
        }
	}
}
//CID 0332 //2009.08.07 //End

//CID 0332 //2009.08.07 //Begin
function InfoJet_UndoOldValueState(){
    if (InfoJet_OldValueState != null && InfoJet_OldValueState.valid) {
        //CID 0387 //2010.11.27 //Begin
        if (!InfoJet_OldValueState.hasField) {
            var xmlField = document.getElementById(InfoJet_OldValueState.fieldId);
            if (xmlField != null) {
                InfoJet_RemoveHtmlElement(xmlField);
            }
        } else {
            if (InfoJet_OldValueState.fieldId != null) {
                var xmlField = document.getElementById(InfoJet_OldValueState.fieldId);
                xmlField.value = InfoJet_OldValueState.fieldValue;
            }
        }
        //CID 0387 //2010.11.27 //End
        
        var control = document.getElementById( InfoJet_OldValueState.controlId );
        var tagName = control.tagName.toLowerCase();
        if( tagName == "select" ){
			control.selectedIndex = InfoJet_OldValueState.selectedIndex;
			if( InfoJet_IsComboBoxControl( control ) ){
				var textField = InfoJet_GetPreviousElement( control );
				textField.value = InfoJet_OldValueState.textValue;
			}
        }else if( tagName == "input" ){
			var type = control.type.toLowerCase();
            if( type == "text" || type == "password" ){
				control.value = InfoJet_OldValueState.textValue;
				if( InfoJet_IsComboBoxControl( control ) ){
					var select = InfoJet_GetNextElement( control );
					select.selectedIndex = InfoJet_OldValueState.selectedIndex;
				}
            }else if( type == "checkbox" ){
				var parentElement = InfoJet_GetParent( control );
				if( parentElement.className == "xdMultiSelectListItem" ){
					control.checked = InfoJet_OldValueState.boolValue;
					var itemValueField = document.getElementById( "xdoc_param_multi_select_list_item_value" );
					if( itemValueField != null ){
						InfoJet_RemoveHtmlElement( itemValueField );
					}
				}else{
					//CID 0387 //2009.08.18 //Begin
				    var value = control.getAttribute(InfoJet_XdPrefix + "value");
				    if (value != null) {
				        var onValue = control.getAttribute(InfoJet_XdPrefix + "onValue");
				        if (value == onValue) {
				            control.checked = true;
				        } else {
				            control.checked = false;
				        }
				    }
				    //CID 0387 //2010.11.26 //End
				}
			}else if( type == "radio" ){
				//CID 0387 //2009.08.18 //Begin
				var value = control.getAttribute( InfoJet_XdPrefix + "value" );
				if( value != null ){
					var radios = document.getElementsByName( control.name );
					for( var i = 0; i < radios.length; i ++ ){
						var radio = radios[ i ];
						var onValue = radio.getAttribute( InfoJet_XdPrefix + "onValue" );
						if( value == onValue ){
							radio.checked = true;
						}else{
							radio.checked = false;
						}
					}
		        }
				//CID 0387 //2010.11.26 //End
			}
        }else if( tagName == "textarea" ){
			control.value = InfoJet_OldValueState.textValue;
        }else if( InfoJet_IsRichTextBox( control ) ){
            control.innerHTML = InfoJet_OldValueState.textValue;
        }
        //CID 0387 //2010.11.26 //Begin
        InfoJet_OldValueState.valid = false;
        //CID 0387 //2010.11.26 //End
        control.focus();
    }
}
//CID 0332 //2009.08.07 //End

//CID 0347 //2009.07.13 //Begin
function InfoJet_OnButtonFocus( event, source ){
	InfoJet_FocusControlId = source.id;
	var isMouseDown = source.getAttribute( "isMouseDown" );
	if( isMouseDown != null && isMouseDown == "true" ){
		source.setAttribute( "isMouseDown", "false" );
		if( InfoJet_Postbacking ){
			//CID 0474 //2009.12.23 //Begin
			InfoJet_CachedPostbackButtonId = source.id;
			//CID 0474 //2009.12.23 //End
			//CID 0380 //2009.09.22 //Begin
			InfoJet_RemoveFocus();
			//CID 0380 //2009.09.22 //End
		}
	}else{
		//CID 0332 //2009.08.07 //Begin
		if( InfoJet_OldValueState != null ){
			InfoJet_OldValueState.valid = false;
			InfoJet_OldValueState.controlId = null;
		}
		//CID 0332 //2009.08.07 //End
	}
}
//CID 0347 //2009.07.13 //End

//CID 0613 //2010.07.20 //Begin
function InfoJet_OnPictureButtonMouseOver(source) {
    var imgElement = InfoJet_GetFirstChild(source);
    if (imgElement != null) {
        var hoverSrc = imgElement.getAttribute(InfoJet_XdPrefix + "HoverSRC");
        if (hoverSrc != null && hoverSrc.length > 0) {
            var oldSrc = imgElement.getAttribute("oldSrc");
            if (oldSrc == null || oldSrc.length <= 0) {
                imgElement.setAttribute("oldSrc", imgElement.src);
                imgElement.src = hoverSrc;
            }
        }
    }
}
//CID 0613 //2010.07.20 //End

//CID 0613 //2010.07.20 //Begin
function InfoJet_OnPictureButtonMouseOut(source) {
    var imgElement = InfoJet_GetFirstChild(source);
    if (imgElement != null) {
        var hoverSrc = imgElement.getAttribute(InfoJet_XdPrefix + "HoverSRC");
        if (hoverSrc != null && hoverSrc.length > 0) {
            var oldSrc = imgElement.getAttribute("oldSrc");
            if (oldSrc != null || oldSrc.length > 0) {
                imgElement.src = oldSrc;
                imgElement.removeAttribute("oldSrc");
            }
        }
    }
}
//CID 0613 //2010.07.20 //End

//CID 0474 //2009.12.23 //Begin
function InfoJet_CheckCachedPostback( isUpdated ){
	if( InfoJet_CachedPostbackButtonId != null )
	{
		if( isUpdated ){
			//CID 0544 //2010.05.12 //Begin
		    if (!InfoJet_HideTryAgainNotification) {
		        //CID 0641 //2010.11.06 //LocalResources
			    alert(InfoJet_LocalResources["ClickAgainMessage"]);
			}
			//CID 0544 //2010.05.12 //End
		}else{
			var button = document.getElementById( InfoJet_CachedPostbackButtonId );
			InfoJet_CachedPostbackButtonId = null;
			if( button != null ){
				if( !( button.style.display == "none" || button.disabled || button.clientWidth == 0 || button.clientHeight == 0 ) ){
					window.setTimeout(function(){ button.onclick(); }, 0);
				}
			}
		}
	}
}
//CID 0474 //2009.12.23 //End

//CID 0474 //2009.12.23 //Begin
function InfoJet_ClearCachedPostback(){
	InfoJet_CachedPostbackButtonId = null;
}
//CID 0474 //2009.12.23 //End

function InfoJet_OnFocus(event, source, type, clicked) {	//CID 0086 //2008.08.14 //clicked
    if( (!InfoJet_IsInited()) && (source.id == "") ){
		return;
	}
	event = InfoJet_GetEvent( event );
	//CID 0291 //2009.05.31 //Begin
	if( InfoJet_IsFocusableControl( source ) ){
		InfoJet_FocusControlId = source.id;
	}
	if( InfoJet_Postbacking ){
		//CID 0380 //2009.09.22 //Begin
		InfoJet_RemoveFocus();
		//CID 0380 //2009.09.22 //End
		return;		
	}
	//CID 0291 //2009.05.31 //End
	
	//CID 0332 //2009.08.07 //Begin
    InfoJet_RecordOldValueState( source );
    //CID 0332 //2009.08.07 //End

	//CID 0080 //2008.08.04 //Begin
	//CID 0086 //2008.08.14 //!clicked
	if( !clicked ){
		//CID 0255 //2009.05.18 //Begin
		//CID 0477 //2009.12.17 //InfoJet_IsSingleLineTextControl
		if( InfoJet_IsSingleLineTextControl( source ) ){
			//CID 0400 //2009.11.23 //Begin
			var noTextSelection = source.getAttribute( "noTextSelection" );
			if( noTextSelection == null ){
				//CID 0472 //2009.12.08 //Begin
				try{
					source.select();
				}catch( srce ){}
				//CID 0472 //2009.12.08 //End
			}else{
				source.removeAttribute( "noTextSelection" );
			}
			//CID 0400 //2009.11.23 //End
		}
		//CID 0255 //2009.05.18 //End
		//CID 1004 //2011.08.06 //Begin
		if (source.tagName.toLowerCase() == "textarea") {
		    if (InfoJet_IsIE()) {
		        var range = source.createTextRange();
		        range.collapse(true);
		        range.select();
		    } else {
		        source.setSelectionRange(0, 0);
		    }
		}
		//CID 1004 //2011.08.06 //End
	}
	//CID 0080 //2008.08.04 //End
	
	if( type == "control" && InfoJet_NeedFieldBorder( source ) ){
		InfoJet_ShowFieldBorder( source , "xdoc_field_focus" );
		InfoJet_SelectTextControlPlaceHolder( source );
	}
	if( !InfoJet_NeedSectionBorder( source ) ){
		var parent = InfoJet_GetParent( source );
		if( parent != null ){
			InfoJet_OnFocus( event , parent , type );
		}
		return;
	}
	var itemElement = InfoJet_RefreshXmlToEditItem( source , true );
	if( itemElement != null ){
		InfoJet_ItemElement = itemElement;
		InfoJet_ShowFocusMenuArrow( itemElement );
		InfoJet_ShowSectionBorder( itemElement , "xdoc_item_focus" );
		event.cancelBubble = true;
    } else {
        //CID 1101 //2012.05.25 //Begin
        //CID 1336 //2012.09.18 //xctname
        var xctname = source.getAttribute( InfoJet_XdPrefix + "xctname" );
        if( xctname != null && xctname == "RichText"  ){
            InfoJet_HideFocusMenuArrow(true);
        } else {
            InfoJet_HideFocusMenuArrow(false);
        }
        //CID 1101 //2012.05.25 //End
	}
	InfoJet_OnMasterDetial( event , source );
}

function InfoJet_UpdateMasterDetial( masterName , curDetialRow ){
	var masterDetials = document.getElementById( "xdoc_param_master_detial" ).value;
	var masterDetialArray = masterDetials.split( ";" );
	for( var i = 0 ; i < masterDetialArray.length ; i ++ ){
		var masterDetial = masterDetialArray[ i ];
		if( masterDetial.length > 0 ){
			var propArray = masterDetial.split( "," );
			var name = propArray[ 0 ];
			var row = propArray[ 1 ];
			if( name == masterName ){
				if( row != curDetialRow ){
					masterDetials = masterDetials.replace( masterName + "," + row , masterName + "," + curDetialRow );
					document.getElementById( "xdoc_param_master_detial" ).value = masterDetials;
					return true;
				}
			}
		}
	}
	return false;
}

function InfoJet_GetMasterDetial( source ){
	var masterDetial = {tbody:null , tr:null };
	var tr = null;
	var masterNameAttr = InfoJet_XdPrefix + "masterName";
	var parent = source;
	while( parent != null ){
		if( parent.tagName ){
			var tagName = parent.tagName.toLowerCase();
			if( tagName == "body" || tagName == "html" ){
				return null;
			}
			if( tagName == "tr" ){
				tr = parent;
			}
			if( tagName != "table" ){	
				var masterName = parent.getAttribute( masterNameAttr );
				if( masterName != null && masterName.length > 0 ){
					masterDetial.tbody = parent;
					masterDetial.tr = tr;
					return masterDetial;
				}
			}
			parent = InfoJet_GetParent( parent );
		}else{
			return null;
		}
	}
}

function InfoJet_GetCurrentDetialRow( masterDetial ){
	var tbody = masterDetial.tbody;
	var tr = masterDetial.tr;
	//CID 0278 //2009.05.02 //Begin
	for( var i = 0; i < tbody.childNodes.length; i ++ ){
		var childNode = tbody.childNodes[ i ];
		if( childNode.nodeType == 1 ){
			if( childNode == tr ){
				return i + 1;
			}
		}
	}
	//CID 0278 //2009.05.02 //End
	return 1;
}

//CID 0372 //2009.08.07 //Begin
function InfoJet_IsRichTextBox( source ){
	//CID 0393 //2009.08.26 //Begin
	try{
		if( source.tagName.toLowerCase() == "span" ){
			var xctname = source.getAttribute( InfoJet_XdPrefix + "xctname" );
			if( xctname != null && xctname == "RichText"  ){
				return true;
			}
		}
	}catch(e){
		return false;
	}
	//CID 0393 //2009.08.26 //End
}
//CID 0372 //2009.08.07 //End

//CID 0372 //2009.08.02 //Begin
function InfoJet_OnRichTextBlur( source ){
	if( InfoJet_IsRichTextBox( source )){
	    //CID 1338 //2012.09.18 //Begin
	    var isEditing = source.getAttribute("isEditing");
	    if (isEditing == "true") {
	        InfoJet_OnNicEditBlur(source);
        }
	    //CID 1338 //2012.09.18 //End
	}
}
//CID 0372 //2009.08.02 //End

function InfoJet_OnBlur( event , source , type ){
    //CID 0769 //2011.01.25 //Begin
    //CID 0372 //2009.08.02 //Begin
    InfoJet_OnRichTextBlur(source);
    //CID 0372 //2009.08.02 //End
    //CID 0769 //2011.01.25 //End
	event = InfoJet_GetEvent( event );
	if( !InfoJet_ShouldContinueBlur() ){
		return;
	}
	//CID 0287 //2009.05.12 //Begin
	if( InfoJet_BrowserQuick ){
		if( InfoJet_IsMultipleLineTextArea( source ) ){
			InfoJet_RelayoutFieldStyles();
		}
	}else{
		if( type == 'control' ){
			InfoJet_HideBorder( "xdoc_field_focus" );
		}
	}
	InfoJet_HideFocusMenuArrow();
	InfoJet_HideBorder( "xdoc_item_focus" );
	InfoJet_HiddenAllGroupMenu();
	//CID 0287 //2009.05.12 //End
}

function InfoJet_OnMouseOver( event , source , type ){
	if( InfoJet_BrowserQuick ){
		return;
	}
	if( (!InfoJet_IsInited()) && (source.id == "") ){
		return;
	}
	event = InfoJet_GetEvent( event );
	if( type == "control" && InfoJet_NeedFieldBorder( source ) ){
		InfoJet_ShowFieldBorder( source , "xdoc_field_over" );
    }
    if (!InfoJet_NeedSectionBorder(source)) {
        return;
	}
    var itemElement = InfoJet_RefreshXmlToEditItem(source, false);
    if (itemElement != null) {
        //CID 0010 //2008.06.05 //Begin
        //InfoJet_ShowOverMenuArrow( itemElement );
        //CID 0010 //2008.06.05 //End
        InfoJet_ShowSectionBorder(itemElement, "xdoc_item_over");
        event.cancelBubble = true;
    }
}

function InfoJet_OnMouseOut( event , source ){
	if( InfoJet_BrowserQuick ){
		return;
	}
	InfoJet_HideOverBorderArrow();
}

function InfoJet_BuildHorizonBorder( borderId , zOrder , width , style , color ){
	var border = "";
	border += "<img id='" + borderId + "' style='";
	border += "z-index: " + zOrder + "; ";
	border += "border-top-width: " + width + "; ";
	border += "border-top-style: " + style + "; "
	border += "border-top-color: " + color + "; ";
	border += "border-right-style: none; ";
	border += "border-bottom-style: none; ";
	border += "border-left-style: none; ";
	border += "width: 0; height: 0; left: 100; top: 100; position: absolute;";
	border += "'>";
	return border;
}

function InfoJet_BuildVerticalBorder( borderId , zOrder , width , style , color ){
	var border = "";
	border += "<img id='" + borderId + "' style='";
	border += "z-index: " + zOrder + "; ";
	border += "border-left-width: " + width + "; ";
	border += "border-left-style: " + style + "; ";
	border += "border-left-color: " + color + "; ";
	border += "border-top-style: none; ";
	border += "border-right-style: none; ";
	border += "border-bottom-style: none; ";
	border += "width: 0; height: 0; left: 100; top: 100; position: absolute;";
	border += "'>";
	return border;
} 

function InfoJet_BuildInvalidateBorder( field ){
	var content = InfoJet_BuildHorizonBorder( field.id + "_top" , 90 , "2px" , "dashed" , "#FF0000" );
	content += InfoJet_BuildHorizonBorder( field.id + "_bottom" , 90 , "2px" , "dashed" , "#FF0000" );
	content += InfoJet_BuildVerticalBorder( field.id + "_left" , 90 , "2px" , "dashed" , "#FF0000" );
	content += InfoJet_BuildVerticalBorder( field.id + "_right" , 90 , "2px" , "dashed" , "#FF0000" );
	return content;
}

function InfoJet_BuildNotBlankMark( field ){
	if( InfoJet_EnableUnderline ){
		var underline = InfoJet_BuildHorizonBorder( field.id + "_notBlank" , 90 , "1pt" , "solid" , "#FF0000" );
		return underline;
	}else{
		var redStar = "";
		redStar += "<img id='" + field.id + "_notBlank' style='";
		redStar += "z-index: 90; display:none; position: absolute;' ";
		redStar += "src='" + InfoJet_WebContext + "images/infojet_red_star.gif'";
		redStar += ">";
		return redStar;
	}
}

function InfoJet_BuildFocusOverBorder(){
	var content = InfoJet_BuildHorizonBorder( "xdoc_item_focus_top" , 96 , "1" , "dashed" , "#0033FF" );
	content += InfoJet_BuildHorizonBorder( "xdoc_item_focus_bottom" , 96 , "1" , "dashed" , "#0033FF" );
	content += InfoJet_BuildVerticalBorder( "xdoc_item_focus_left" , 96 , "1" , "dashed" , "#0033FF" );
	content += InfoJet_BuildVerticalBorder( "xdoc_item_focus_right" , 96 , "1" , "dashed" , "#0033FF" );
	
	content += InfoJet_BuildHorizonBorder( "xdoc_item_over_top" , 97 , "1" , "dashed" , "#716F64" );
	content += InfoJet_BuildHorizonBorder( "xdoc_item_over_bottom" , 97 , "1" , "dashed" , "#716F64" );
	content += InfoJet_BuildVerticalBorder( "xdoc_item_over_left" , 97 , "1" , "dashed" , "#716F64" );
	content += InfoJet_BuildVerticalBorder( "xdoc_item_over_right" , 97 , "1" , "dashed" , "#716F64" );
	
	content += InfoJet_BuildHorizonBorder( "xdoc_field_focus_top" , 96 , "1" , "solid" , "#0033FF" );
	content += InfoJet_BuildHorizonBorder( "xdoc_field_focus_bottom" , 96 , "1" , "solid" , "#0033FF" );
	content += InfoJet_BuildVerticalBorder( "xdoc_field_focus_left" , 96 , "1" , "solid" , "#0033FF" );
	content += InfoJet_BuildVerticalBorder( "xdoc_field_focus_right" , 96 , "1" , "solid" , "#0033FF" );
	
	content += InfoJet_BuildHorizonBorder( "xdoc_field_over_top" , 97 , "1" , "solid" , "#716F64" );
	content += InfoJet_BuildHorizonBorder( "xdoc_field_over_bottom" , 97 , "1" , "solid" , "#716F64" );
	content += InfoJet_BuildVerticalBorder( "xdoc_field_over_left" , 97 , "1" , "solid" , "#716F64" );
	content += InfoJet_BuildVerticalBorder("xdoc_field_over_right", 97, "1", "solid", "#716F64");

	var focusOver = document.getElementById( "xdoc_focusover" );
	focusOver.innerHTML = content;

	//CID 0673 //2010.09.29 //Begin
	InfoJet_ItemOverTop = document.getElementById("xdoc_item_over_top");
	InfoJet_ItemOverBottom = document.getElementById("xdoc_item_over_bottom");
	InfoJet_ItemOverLeft = document.getElementById("xdoc_item_over_left");
	InfoJet_ItemOverRight = document.getElementById("xdoc_item_over_right");
	InfoJet_FieldOverTop = document.getElementById("xdoc_field_over_top");
	InfoJet_FieldOverBottom = document.getElementById("xdoc_field_over_bottom");
	InfoJet_FieldOverLeft = document.getElementById("xdoc_field_over_left");
	InfoJet_FieldOverRight = document.getElementById("xdoc_field_over_right");
	InfoJet_ItemFocusTop = document.getElementById("xdoc_item_focus_top");
	InfoJet_ItemFocusBottom = document.getElementById("xdoc_item_focus_bottom");
	InfoJet_ItemFocusLeft = document.getElementById("xdoc_item_focus_left");
	InfoJet_ItemFocusRight = document.getElementById("xdoc_item_focus_right");
	InfoJet_FieldFocusTop = document.getElementById("xdoc_field_focus_top");
	InfoJet_FieldFocusBottom = document.getElementById("xdoc_field_focus_bottom");
	InfoJet_FieldFocusLeft = document.getElementById("xdoc_field_focus_left");
	InfoJet_FieldFocusRight = document.getElementById("xdoc_field_focus_right");
	//CID 0673 //2010.09.29 //End
}

function InfoJet_ShowFieldBorder( targetElement , borderId ){
	//CID 0287 //2009.05.11 //Begin
	if( InfoJet_BrowserQuick ){
		return;
	}
	//CID 0287 //2009.05.11 //End
	var pos = InfoJet_GetPos( targetElement );
	//CID 0501 //2010.01.23 //Begin
	if( pos == null ){
		return;
	}
	//CID 0501 //2010.01.23 //End
	
	var borderLeft = document.getElementById( borderId + "_left" );
	if( borderLeft == null ){
		return;
	}
	borderLeft.style.left = pos.left;
	borderLeft.style.top = pos.top;
	borderLeft.style.height = targetElement.offsetHeight;
	
	var borderRight = document.getElementById( borderId + "_right" );
	borderRight.style.left = pos.left + targetElement.offsetWidth - 1;
	borderRight.style.top = pos.top;
	borderRight.style.height = targetElement.offsetHeight;
	
	var borderTop = document.getElementById( borderId + "_top" );
	borderTop.style.left = pos.left;
	borderTop.style.top = pos.top;
	borderTop.style.width = targetElement.offsetWidth;
	
	var borderBottom = document.getElementById( borderId + "_bottom" );
	borderBottom.style.left = pos.left;
	borderBottom.style.top = pos.top + targetElement.offsetHeight - 1;
	borderBottom.style.width = targetElement.offsetWidth;
}

function InfoJet_ShowInvalidateBorder( targetElement ){
	//CID 0280 //2009.05.12 //Begin
	var borderId = targetElement.id;
	//CID 0280 //2009.05.12 //End
	var borderLeft = document.getElementById( borderId + "_left" );
	if( borderLeft == null ){
		var border = InfoJet_BuildInvalidateBorder( targetElement );
		var fieldStyle = document.getElementById( "xdoc_fieldstyle" );
		//fieldStyle.insertAdjacentHTML( "BeforeEnd", border );
		//CID 0017 //2008.06.16 //Begin
		InfoJet_InsertAdjacentHTMLBeforeEnd( fieldStyle, border );
		//CID 0017 //2008.06.16 //End
		
		borderLeft = document.getElementById( borderId + "_left" );
	} 
	
	var pos = InfoJet_GetPos( targetElement );
	//CID 0501 //2010.01.23 //Begin
	if( pos == null ){
		return;
	}
	//CID 0501 //2010.01.23 //End
	
	var isSelect = InfoJet_IsSelect( targetElement );
	var selectOffset = 0;
	if( isSelect ){
		pos.left = pos.left - 2;
		pos.top = pos.top - 2;
		selectOffset = 4;
	}

	var borderLeftWidth = InfoJet_GetStylePixelSize( targetElement , "borderLeftWidth" , "border-left-width" );
	var borderTopWidth = InfoJet_GetStylePixelSize( targetElement , "borderTopWidth" , "border-top-width" );
	var borderRightWidth = InfoJet_GetStylePixelSize( targetElement , "borderRightWidth" , "border-right-width" );
	var borderBottomWidth = InfoJet_GetStylePixelSize( targetElement , "borderBottomWidth" , "border-bottom-width" );
	
	//有时候offsetHeight和offsetWidth是0.
	var height = 0;
	
	borderLeft.style.left = pos.left + borderLeftWidth - 2;
	borderLeft.style.top = pos.top + borderTopWidth - 2;
	height = targetElement.offsetHeight - borderTopWidth - borderBottomWidth + 2 + selectOffset;
	if( height >= 0 ){
		borderLeft.style.height = height;
	}
	
	var borderRight = document.getElementById( borderId + "_right" );
	borderRight.style.left = pos.left + targetElement.offsetWidth - borderRightWidth + selectOffset;
	borderRight.style.top = pos.top + borderTopWidth - 2;
	height = targetElement.offsetHeight - borderTopWidth - borderBottomWidth + 2 + selectOffset;
	if( height >= 0 ){
		borderRight.style.height = height;
	}
	
	var width = 0;
	
	var borderTop = document.getElementById( borderId + "_top" );
	borderTop.style.left = pos.left + borderLeftWidth - 2;
	borderTop.style.top = pos.top + borderTopWidth - 2;
	width = targetElement.offsetWidth - borderLeftWidth - borderRightWidth + 2 + selectOffset;
	if( width >= 0 ){
		borderTop.style.width = width;
	}
	
	var borderBottom = document.getElementById( borderId + "_bottom" );
	borderBottom.style.left = pos.left + borderLeftWidth - 2;
	borderBottom.style.top = pos.top + targetElement.offsetHeight - borderBottomWidth + selectOffset;
	width = targetElement.offsetWidth - borderLeftWidth - borderRightWidth + 2 + selectOffset;
	if( width >= 0 ){
		borderBottom.style.width = width;
	}
}

function InfoJet_ShowNotBlankMark( control ){	
	var notBlankMark = document.getElementById( control.id + "_notBlank" );
	if( notBlankMark == null ){
		var notBlankMarkHtml = InfoJet_BuildNotBlankMark( control );
		var fieldStyle = document.getElementById( "xdoc_fieldstyle" );
		//fieldStyle.insertAdjacentHTML( "BeforeEnd", notBlankMarkHtml );
		//CID 0017 //2008.06.16 //Begin
		InfoJet_InsertAdjacentHTMLBeforeEnd( fieldStyle, notBlankMarkHtml );
		//CID 0017 //2008.06.16 //End
		
		notBlankMark = document.getElementById( control.id + "_notBlank" );
    }

    //CID 0858 //2011.03.29 //Begin
    if (control.tagName) {
        //CID 0861 //2011.04.12 //Begin
        var tagName = control.tagName.toLowerCase();
        var pos = InfoJet_GetPos(control);
        if (pos == null) {
            return;
        }
        //CID 1208 //2012.05.28 //if span
        if (tagName == "div" || tagName == "span") {
            notBlankMark.style.left = pos.left + control.offsetWidth - 12;
            notBlankMark.style.top = pos.top + (control.offsetHeight - 8) / 2;
            notBlankMark.style.display = "block";
            return;
        }else if(tagName == "a" || tagName == "img"){
            notBlankMark.style.left = pos.left + control.offsetWidth - 10;
            notBlankMark.style.top = pos.top + 2;
            notBlankMark.style.display = "block";
            return;
        }
        //CID 0861 //2011.04.12 //End
    }
    //CID 0858 //2011.03.29 //End
	
	var isGhosted = false;
	var ghosted = control.getAttribute( InfoJet_XdPrefix + "ghosted" );
	if( ghosted != null && ghosted == "true" ){
		isGhosted = true;
	}
	
	if( control.value.length <= 0 || isGhosted ){
		var pos = InfoJet_GetPos( control );
		//CID 0501 //2010.01.23 //Begin
		if( pos == null ){
			return;
		}
		//CID 0501 //2010.01.23 //End
		if( InfoJet_EnableUnderline ){
			notBlankMark.style.left = pos.left;
			notBlankMark.style.top = pos.top + control.offsetHeight;
			notBlankMark.style.width = control.offsetWidth;
		}else{
		    var tagName = control.tagName.toLowerCase();
		    if (tagName == "select") {
		        if (InfoJet_IsIE7()) { //CID 0515 //2010.03.24 //IsIE7
		            notBlankMark.style.left = pos.left + control.offsetWidth - 29;
		            notBlankMark.style.top = pos.top + 4;
		        } else {
		            notBlankMark.style.left = pos.left + control.offsetWidth + 2;
		            notBlankMark.style.top = pos.top + 4;
		        }
		    } else {
		        //CID 1147 //2012.03.28 //Begin
		        if (InfoJet_RedAsteriskOTA) {
		            //CID 0642 //2010.08.17 //Begin
		            if (control.style.textAlign == "right") {
		                notBlankMark.style.left = pos.left + 4;
		                notBlankMark.style.top = pos.top + (control.offsetHeight - 8) / 2;
		            } else {
		                notBlankMark.style.left = pos.left + control.offsetWidth - 12;
		                notBlankMark.style.top = pos.top + (control.offsetHeight - 8) / 2;
		            }
		            //CID 0642 //2010.08.17 //End
		        } else {
		            notBlankMark.style.left = pos.left + control.offsetWidth - 12;
		            notBlankMark.style.top = pos.top + (control.offsetHeight - 8) / 2;
		        }
		        //CID 1147 //2012.03.28 //End
		    }
		}
		notBlankMark.style.display = "block";
	}else{
		notBlankMark.style.display = "none";
	}
}

function InfoJet_ShowSectionBorder( targetElement , borderId ){
	var pos = InfoJet_GetPos( targetElement );
	//CID 0501 //2010.01.23 //Begin
	if( pos == null ){
		return;
	}
	//CID 0501 //2010.01.23 //End
	
	var borderLeftWidth = InfoJet_GetStylePixelSize( targetElement , "borderLeftWidth" , "border-left-width" );
	var borderTopWidth = InfoJet_GetStylePixelSize( targetElement , "borderTopWidth" , "border-top-width" );
	var borderRightWidth = InfoJet_GetStylePixelSize( targetElement , "borderRightWidth" , "border-right-width" );
	var borderBottomWidth = InfoJet_GetStylePixelSize( targetElement , "borderBottomWidth" , "border-bottom-width" );
	
	var borderLeft = document.getElementById( borderId + "_left" );
	borderLeft.style.left = pos.left + borderLeftWidth - 1;
	borderLeft.style.top = pos.top + borderTopWidth - 1;
	borderLeft.style.height = targetElement.offsetHeight - borderTopWidth - borderBottomWidth;
	
	var borderRight = document.getElementById( borderId + "_right" );
	borderRight.style.left = pos.left + targetElement.offsetWidth - borderRightWidth;
	borderRight.style.top = pos.top + borderTopWidth;
	borderRight.style.height = targetElement.offsetHeight - borderTopWidth - borderBottomWidth;
	
	var borderTop = document.getElementById( borderId + "_top" );
	borderTop.style.left = pos.left + borderLeftWidth - 1;
	borderTop.style.top = pos.top + borderTopWidth - 1;
	borderTop.style.width = targetElement.offsetWidth - borderLeftWidth - borderRightWidth;
	
	var borderBottom = document.getElementById( borderId + "_bottom" );
	borderBottom.style.left = pos.left + borderLeftWidth;
	borderBottom.style.top = pos.top + targetElement.offsetHeight - borderBottomWidth;
	borderBottom.style.width = targetElement.offsetWidth - borderLeftWidth - borderRightWidth;
}

function InfoJet_ShowFocusMenuArrow( itemElement ){
	if( !InfoJet_ShowMenuArrow ){
		return;
	}
	var focusMenuArrowImg = document.getElementById( "xdoc_menu_focus_arrow_img" );
	var xctName = itemElement.getAttribute( InfoJet_XdPrefix + "xctname" );
	if( xctName == "Section" ){
		focusMenuArrowImg.src = InfoJet_WebContext + "images/infojet_menu_xoptional_focus_arrow.gif";
	}else if( xctName == "choiceterm" || xctName == "choicetermrepeating" ){
		focusMenuArrowImg.src = InfoJet_WebContext + "images/infojet_menu_xreplace_focus_arrow.gif";
	}else{
		focusMenuArrowImg.src = InfoJet_WebContext + "images/infojet_menu_xcollection_focus_arrow.gif";
	}
	var pos = InfoJet_GetPos( itemElement );
	//CID 0501 //2010.01.23 //Begin
	if( pos == null ){
		return;
	}
	//CID 0501 //2010.01.23 //End
	var focusMenuArrow = document.getElementById( "xdoc_menu_focus_arrow" );
	focusMenuArrow.style.left = pos.left - 18 + 2;
	focusMenuArrow.style.top = pos.top + 2;
	focusMenuArrow.style.display = "block";
}

//CID 0010 //2008.06.05 //To Remove
function InfoJet_ShowOverMenuArrow( itemElement ){
	if( !InfoJet_ShowMenuArrow ){
		return;
	}
	var overMenuArrowImg = document.getElementById( "xdoc_menu_over_arrow_img" );
	var xctName = itemElement.getAttribute( InfoJet_XdPrefix + "xctname" );
	if( xctName == "Section" ){
		overMenuArrowImg.src = InfoJet_WebContext + "images/infojet_menu_xoptional_over_arrow.gif";
	}else if( xctName == "choiceterm" || xctName == "choicetermrepeating" ){
		overMenuArrowImg.src = InfoJet_WebContext + "images/infojet_menu_xreplace_over_arrow.gif";
	}else{
		overMenuArrowImg.src = InfoJet_WebContext + "images/infojet_menu_xcollection_over_arrow.gif";
	}
	var pos = InfoJet_GetPos( itemElement );
	//CID 0501 //2010.01.23 //Begin
	if( pos == null ){
		return;
	}
	//CID 0501 //2010.01.23 //End
	var overMenuArrow = document.getElementById( "xdoc_menu_over_arrow" );
	overMenuArrow.style.left = pos.left - 18 + 2;
	overMenuArrow.style.top = pos.top + 2;
	overMenuArrow.style.display = "block";
}

//CID 0010 //2008.06.05 //To Remove
function InfoJet_HideOverMenuArrow(){
	var overMenuArrow = document.getElementById( "xdoc_menu_over_arrow" );
	if( overMenuArrow != null ){
		overMenuArrow.style.display = "none";	
	}
}

function InfoJet_HideBorder( borderId ){
	InfoJet_HideDashedBorder( borderId );
	InfoJet_HideNotBlankMark( borderId );
}

function InfoJet_HideDashedBorder( borderId ){
	var borderLeft = document.getElementById( borderId + "_left" );
	if( borderLeft == null ){
		return;
	}
	borderLeft.style.height = 0;
	var borderRight = document.getElementById( borderId + "_right" );
	borderRight.style.height = 0;
	var borderTop = document.getElementById( borderId + "_top" );
	borderTop.style.width = 0;
	var borderBottom = document.getElementById( borderId + "_bottom" );
	borderBottom.style.width = 0;
}

function InfoJet_HideNotBlankMark( borderId ){
	var borderNotBlank = document.getElementById( borderId + "_notBlank" );
	if( borderNotBlank != null ){
		borderNotBlank.style.display = "none";
	}
}

function InfoJet_HideFocusMenuArrow(hideArrowOnly) {
	var focusMenuArrow = document.getElementById( "xdoc_menu_focus_arrow" );
	if( focusMenuArrow ){
		focusMenuArrow.style.display = "none";
    }
    //CID 1366 //2012.10.04 //Begin
    if(!InfoJet_EditRichTextOnFocus){
        //CID 1101 //2012.05.23 //Begin
        if (!hideArrowOnly) {
            var rtbEditMenu = document.getElementById("xdoc_menu_rtb_edit");
            if (rtbEditMenu) {
                rtbEditMenu.style.display = "none";
            }
        }
        //CID 1101 //2012.05.25 //End
    }
    //CID 1366 //2012.10.04 //End
}

function InfoJet_HideAllErrors(){
	if( InfoJet_NoValidation ){
		return;
	}
	var xdocError = document.getElementById( "xdoc_data_error" );
	if( xdocError == null ){
		return;
	}
	//CID 0278 //2009.05.02 //childNodes
	for( var i = 0; i < xdocError.childNodes.length; i ++ ){
		var error = xdocError.childNodes[ i ];
		if( error.nodeType == 1 ){
			var jetId = error.getAttribute( "JetId" );
			InfoJet_HideError( jetId );
		}
	}
}

function InfoJet_HideError( id ){
	var jetId = InfoJet_GetPureId( id );
	var invalidateId = jetId;
	for( var n = 0 ; true ; n ++ ){
		if( n != 0 ){
			invalidateId = jetId + "," + n;
		}
		var field = document.getElementById( invalidateId );
		if( field == null ){
			break;
		}else{
			//CID 0280 //2009.05.12 //Begin
			InfoJet_HideNecessaryInvalidateBorder( field );
			//CID 0280 //2009.05.12 //End
			InfoJet_ResetTitle( field );
		}
	}
}

function InfoJet_ShowSchemaError( id ){
	var jetId = InfoJet_GetPureId( id );
	for( var n = 0 ; true ; n ++ ){
		var invalidateId = jetId;
		if( n != 0 ){
			invalidateId = jetId + "," + n;
		}
		var field = document.getElementById( invalidateId );
		if( field == null ){
			break;
		}else{
			InfoJet_ShowNecessaryInvalidateBorder( field );
		}
	}
}

function InfoJet_ShowAllErrors() {
    if( InfoJet_NoValidation ){
		return;
	}
	var xdocError = document.getElementById( "xdoc_data_error" );
	if( xdocError == null ){
		return;
	}
	//CID 0278 //2009.05.02 //childNodes
	for( var i = 0; i < xdocError.childNodes.length; i ++ ){
		var error = xdocError.childNodes[ i ];
		if( error.nodeType == 1 ){
			var id = error.getAttribute( "JetId" );
			var type = error.getAttribute( "type" );
			var jetId = InfoJet_GetPureId( id );
			if( type == "schema" ){
				for( var n = 0 ; true ; n ++ ){
					var invalidateId = jetId;
					if( n != 0 ){
						invalidateId = jetId + "," + n;
					}
					//CID 0384 //2009.08.12 //Begin
					if( invalidateId.length <= 0 ){
						continue;
					}
					//CID 0384 //2009.08.12 //End
					var field = document.getElementById( invalidateId );
					if( field == null ){
						break;
					}else{
						InfoJet_ShowNecessaryInvalidateBorder( field );
					}
				}
			}else if( type == "condition" ){
				for( var n = 0 ; true ; n ++ ){
					var invalidateId = jetId;
					if( n != 0 ){
						invalidateId = jetId + "," + n;
					}
					//CID 0384 //2009.08.12 //Begin
					if( invalidateId.length <= 0 ){
						continue;
					}
					//CID 0384 //2009.08.12 //End
					var field = document.getElementById( invalidateId );
					if( field == null ){
						break;
		            } else {
		                //CID 0858 //2011.03.29 //Begin
		                var isPicker = field.getAttribute("isPicker");
		                if (isPicker && isPicker == "true") {
		                    var td = InfoJet_GetFirstChild(field);
		                    var div = InfoJet_GetFirstChild(td);
		                    InfoJet_ShowNotBlankMark(div);
		                    InfoJet_ShowTitle(field, error.innerHTML);
		                } 
                        else {
		                    InfoJet_ShowNecessaryInvalidateBorder(field);
		                    InfoJet_ShowTitle(field, error.innerHTML);
		                }
		                //CID 0858 //2011.03.29 //End
					}
				}
			}else if( type == "program" ){
				for( var n = 0 ; true ; n ++ ){
					var invalidateId = jetId;
					if( n != 0 ){
						invalidateId = jetId + "," + n;
					}
					//CID 0384 //2009.08.12 //Begin
					if( invalidateId.length <= 0 ){
						continue;
					}
					//CID 0384 //2009.08.12 //End
					var field = document.getElementById( invalidateId );
					if( field == null ){
						break;
					}else{
						InfoJet_ShowNecessaryInvalidateBorder( field );
						InfoJet_ShowTitle( field, error.innerHTML );
					}
				}
			}
		}
	}
}

function InfoJet_AddSchemaError( id ){
	var xdocError = document.getElementById( "xdoc_data_error" );
	if( xdocError == null ){
		return;
	}
	var found = false;
	//CID 0278 //2009.05.02 //childNodes
	for( var i = 0; i < xdocError.childNodes.length; i ++ ){
		var error = xdocError.childNodes[ i ];
		if( error.nodeType == 1 ){
			var jetId = error.getAttribute( "JetId" );
			var type = error.getAttribute( "type" );
			if( id == jetId && type == "schema" ){
				found = true;
				break;
			}
		}
	}
	if( !found ){
		var div = "<div JetId='" + id + "' type='schema' style='display:none'></div>";
		//xdocError.insertAdjacentHTML( "BeforeEnd", div );
		//CID 0017 //2008.06.16 //Begin
		InfoJet_InsertAdjacentHTMLBeforeEnd( xdocError, div );
		//CID 0017 //2008.06.16 //End
	}
}

function InfoJet_RemoveError( id, errorType ){
	var removeId = InfoJet_GetPureId( id );
	var xdocError = document.getElementById( "xdoc_data_error" );
	if( xdocError == null ){
		return;
	}
	var foundErrors = new Array();
	//CID 0278 //2009.05.02 //childNodes
	for( var i = 0; i < xdocError.childNodes.length; i ++ ){
		var error = xdocError.childNodes[ i ];
		if( error.nodeType == 1 ){
			var jetId = error.getAttribute( "JetId" );
			var type = error.getAttribute( "type" );
			if( InfoJet_PureIdEquals( removeId, jetId ) && type == errorType ){
				foundErrors.push( error );
			}
		}
	}
	//CID 0279 //2009.05.05 //Begin
	for( var i = 0; i < foundErrors.length; i ++ ){
		var error = foundErrors[ i ];
		//CID 0020 //2008.06.19 //Begin
		InfoJet_RemoveHtmlElement( error );
		//CID 0020 //2008.06.19 //End		
	}
	//CID 0279 //2009.05.05 //End
}

function InfoJet_RemoveErrors( errorType ){
	var xdocError = document.getElementById( "xdoc_data_error" );
	if( xdocError == null ){
		return;
	}
	//CID 0278 //2009.05.05 //Begin
	var errors = new Array();
	for( var i = 0; i < xdocError.childNodes.length; i ++ ){
		var error = xdocError.childNodes[ i ];
		if( error.nodeType == 1 ){
			var type = error.getAttribute( "type" );
			if( type == errorType ){
				errors.push( error );
			}
		}
	}
	for( var i = 0; i < errors.length; i ++ ){
		var error = errors[ i ];
		//CID 0020 //2008.06.19 //Begin
		InfoJet_RemoveHtmlElement( error );
		//CID 0020 //2008.06.19 //End
	}
	//CID 0278 //2009.05.05 //End
}

function InfoJet_AddError( id, message, type ){
	var xdocError = document.getElementById( "xdoc_data_error" );
	if( xdocError == null ){
		return;
	}
	var div = "<div JetId='" + id + "' type='" + type + "' style='display:none'>" + message + "</div>";
	//xdocError.insertAdjacentHTML( "BeforeEnd", div );
	//CID 0017 //2008.06.16 //Begin
	InfoJet_InsertAdjacentHTMLBeforeEnd( xdocError, div );
	//CID 0017 //2008.06.16 //End
}

function InfoJet_ShowTitle( control , title ){
	var bakTitle = control.getAttribute( "title_bak" );
	if( bakTitle !=null ){
		if( bakTitle.length > 0 ){
			control.title = title + "\n" + bakTitle;
		}else{
			control.title = title;
		}
	}else{
		control.setAttribute( "title_bak" , control.title );
		if( control.title.length > 0 ){
			control.title = title + "\n" + control.title;
		}else{
			control.title = title;
		}
	}
}

function InfoJet_ResetTitle( control ){
	var bakTitle = control.getAttribute( "title_bak" );
	if( bakTitle !=null ){
		control.title = bakTitle;
		control.removeAttribute( "title_bak" );
	}
}

//CID 0280 //2009.05.12 //Begin
function InfoJet_HideNecessaryInvalidateBorder( control ){
	if( InfoJet_NoValidation ){
		return;
    }
	InfoJet_HideBorder( control.id );
}
//CID 0280 //2009.05.12 //End

function InfoJet_ShowNecessaryInvalidateBorder( control ){
	if( InfoJet_NoValidation ){
		return;
    }

    //CID 1154 //2012.04.06 //Begin
    if (control.disabled) {
        return;
    }
    //CID 1154 //2012.04.06 //End
	
	//CID 0223 //2009.03.17 //Begin
	var comboTextValue = null;
	if( control.className != null && control.className.indexOf( "ComboBoxTextField" ) > 0 ){
		var xctname = InfoJet_GetParent( control ).getAttribute( InfoJet_XdPrefix + "xctname" );
		if( xctname != null && xctname.toLowerCase() == "combobox" ){
			return;
		}
	}
	//CID 0223 //2009.03.17 //End

	var tagName = control.tagName.toLowerCase();
	//CID 0861 //2011.04.11 //Begin
	if (tagName == "a") {
	    InfoJet_ShowNotBlankMark(control);
	    return;
	}else if(tagName == "img"){
	    InfoJet_ShowNotBlankMark(control);
	    return;
	}
	//CID 0861 //2011.04.11 //End

	//CID 1208 //2012.05.28 //Begin
    //CID 1382 //2012.10.09 //Begin
    if (tagName == "span") {
        if (InfoJet_GetText(control).length <= 0) {
            InfoJet_HideDashedBorder(control.id);
            InfoJet_ShowNotBlankMark(control);
	    } else {
            InfoJet_HideNotBlankMark(control.id);
            InfoJet_ShowInvalidateBorder(control);
	    }
    }
    //CID 1382 //2012.10.09 //End
	//CID 1208 //2012.05.28 //End
	
	if( tagName == "input" || tagName == "textarea" || tagName == "select" ){
		var ghosted = control.getAttribute( InfoJet_XdPrefix + "ghosted" );
		if( ghosted != null && ghosted == "true" ){
			InfoJet_HideDashedBorder( control.id );
			InfoJet_ShowNotBlankMark( control );
		}else{
			var controlValue = control.value;
			//CID 0223 //2009.03.17 //Begin
			if( tagName == "select" && control.className != null && control.className.indexOf( "xdComboBox" ) >= 0 ){
				var xctname = InfoJet_GetParent( control ).getAttribute( InfoJet_XdPrefix + "xctname" );
				if( xctname != null && xctname.toLowerCase() == "combobox" ){
					var optionValue = null;
					//CID 0255 //2009.05.19 //InfoJet_GetPreviousElement( control );
					var textField = InfoJet_GetPreviousElement( control );
					var textValue = textField.value;
					for( var i = 0; i < control.options.length; i++ ){
						var optionText = control.options[ i ].text;
						if( optionText != null && textValue == optionText ){
							optionValue = control.options[ i ].value;
							break;
						}
					}
					if( optionValue != null ){
						controlValue = optionValue;
					}else{
						controlValue = textValue;
						control.value = textValue;
					}
				}
			}
			//CID 0223 //2009.03.17 //End
			//CID 1131 //2012.03.13 //Begin
			//CID 1153 //2012.04.06 //Begin
			var controlType = control.getAttribute("type");
			if (controlType != null) {
			    controlType = controlType.toLowerCase();
			}
			if (controlType && ( controlType == "radio" || controlType == "checkbox" ) ) {
			    InfoJet_HideNotBlankMark(control.id);
			    InfoJet_ShowInvalidateBorder(control);
			} else {
			    if (controlValue != null && controlValue.length > 0) {
			        InfoJet_HideNotBlankMark(control.id);
			        InfoJet_ShowInvalidateBorder(control);
			    } else {
			        InfoJet_HideDashedBorder(control.id);
			        InfoJet_ShowNotBlankMark(control);
			    }
			}
			//CID 1153 //2012.04.06 //End
			//CID 1131 //2012.03.13 //End
		}
	}
}

function InfoJet_RefreshContext( source ){
	var idArray = "";
	var id = InfoJet_GetElementId( source );
	var element = source;
	while( id != "xdoc_view" ){
		if( id.indexOf( "_0_" ) == 0 ){
			idArray = idArray + id + ";";
		}
		element = InfoJet_GetParent(element);
		id = InfoJet_GetElementId( element );
	}
	if( idArray.length > 0 ){
		idArray = idArray.substr( 0 , idArray.length - 1 );
	}
	document.getElementById( "xdoc_param_context_id_array" ).value = idArray;
}

function InfoJet_GetInnerMostContextId( source ){
	var element = InfoJet_GetParent( source );
	var id = element.id;
	while( id != "xdoc_view" ){
		if( id.indexOf( "_0_" ) == 0 ){
			return id;
		}
		//CID 0230 //2009.02.26 //Begin
		if( id.indexOf( "_s_" ) == 0 ){
			return id;
		}
		//CID 0230 //2009.02.26 //End
		element = InfoJet_GetParent( element );
		id = InfoJet_GetElementId( element );
	}
	return document.getElementById( "xdoc_data_root_element_id" ).innerHTML;
}

function InfoJet_IsFuncDefined( funcName ){
	var stat = "typeof( " + funcName + " ) != 'undefined';";
	return eval( stat );
}

//CID 0263 //2009.03.31 //Begin
function InfoJet_IsButton( control ){
	var tagName = control.tagName.toLowerCase();
	if( tagName == "input" ){
		var type = control.getAttribute( "type" );
		if( type != null ){
			type = type.toLowerCase();
			if( type == "button" ){
				return true;
			}
		}
	}
	return false;
}
//CID 0263 //2009.03.31 //End

function InfoJet_OnMasterDetial( event , source ){
	//To improve the performance, check xdoc_param_master_detial first.
	var masterDetials = document.getElementById( "xdoc_param_master_detial" ).value;
	if( masterDetials.length <= 0 ){
		return;
	}
	var masterNameAttr = InfoJet_XdPrefix + "masterName";
	var masterDetial = InfoJet_GetMasterDetial( source );
	if( masterDetial != null ){
		if( masterDetial.tbody != null && masterDetial.tr != null ){
			//Start to handler the master detials from here.
			var masterName = masterDetial.tbody.getAttribute( masterNameAttr );
			var curDetialRow = InfoJet_GetCurrentDetialRow( masterDetial );
			InfoJet_DoMasterDetail( source, masterName, curDetialRow );
		}
	}
}

function InfoJet_DoMasterDetail( source, masterName, curDetialRow ){
	//CID 0081 //2009.09.29 //Begin
	if( InfoJet_GetParent( source ) == null ){
		return;
	}
	//CID 0081 //2009.09.29 //End
	InfoJet_MoveProgress2ControlPosition( source );
	if( InfoJet_UpdateMasterDetial( masterName , curDetialRow ) ){
		document.getElementById( "xdoc_param_command" ).value = "Update_Refresh";
		InfoJet_Submit();
	}
}

function InfoJet_RefreshAfaterUpdate( control ){
	if( InfoJet_NoPostback ){
		return;
	}
	InfoJet_MoveProgress2ControlPosition( control );
	document.getElementById( "xdoc_param_update_id" ).value = control.id;
	document.getElementById( "xdoc_param_update_format" ).value = control.getAttribute( InfoJet_XdPrefix + "datafmt" );
	document.getElementById( "xdoc_param_command" ).value = "Update_Refresh";
	//CID 0255 //2009.05.18 //Begin
	InfoJet_FocusControlId = control.id;
	//CID 0255 //2009.05.18 //End
	InfoJet_Submit();
}

function InfoJet_CheckClickFrequently( source ){
	if( InfoJet_Postbacking > 0 ){
		//CID 0544 //2010.05.12 //Begin
	    if (!InfoJet_HideTryAgainNotification) {
	        //CID 0641 //2010.11.06 //LocalResources
		    alert(InfoJet_LocalResources["TryAgainMessage"]);
		}
		//CID 0544 //2010.05.12 //End
		//Don't return InfoJet_Postbacking directly.
		return true;
	}else{
		if( source == null ){
			//No source found.
			//CID 0544 //2010.05.12 //Begin
		    if (!InfoJet_HideTryAgainNotification) {
		        //CID 0641 //2010.11.06 //LocalResources
			    alert(InfoJet_LocalResources["TryAgainMessage"]);
			}
			//CID 0544 //2010.05.12 //End
			return true;
		}
		var parent = InfoJet_GetParent( source );
		if( parent == null ){
			//The view is updated by another postback.
			//CID 0544 //2010.05.12 //Begin
		    if (!InfoJet_HideTryAgainNotification) {
		        //CID 0641 //2010.11.06 //LocalResources
			    alert(InfoJet_LocalResources["TryAgainMessage"]);
			}
			//CID 0544 //2010.05.12 //End
			return true;
		}
		return false;
	}
}

function InfoJet_OnPlaceholderClick( event , placeholder ){
	//CID 0347 //2009.07.19 //Begin
	placeholder.setAttribute( "isMouseDown", "false" );
	//CID 0347 //2009.07.19 //End
	//CID 0096 //2009.10.08 //Begin
	if( !InfoJet_IsIE() ){
		var disabled = placeholder.getAttribute( "disabled" );
		if( disabled != null && disabled == "true" ){
			return;
		}
	}
	//CID 0096 //2009.10.08 //End
	//CID 0108 //2008.09.01 //Begin
	var xmlToEdit = placeholder.getAttribute( InfoJet_XdPrefix + "xmlToEdit" );
	var xmlToEditDisabled = "-" + xmlToEdit + "-editing: disabled"
	var parent = InfoJet_GetParent(placeholder);
	while( parent != null ){
		var style = parent.style.cssText;
		if( style != null && style.indexOf( xmlToEditDisabled ) > 0 )
		{
			return;
		}
		parent = InfoJet_GetParent(parent);
		if( parent != null && parent.id == "xdoc_view" ){
			break;
		}
	}
	//CID 0108 //2008.09.01 //End
	if( InfoJet_CheckClickFrequently( placeholder ) ){
		return;
	}
	var xmlToEditName = placeholder.getAttribute( InfoJet_XdPrefix + "xmlToEdit" );
	var xmlToEditAction = placeholder.getAttribute( InfoJet_XdPrefix + "action" );
	if( (!InfoJet_IsViewValid()) && InfoJet_IsIdInArray( xmlToEditName , "xdoc_data_valid_view_xmltoedit_list" ) ){
	    if (xmlToEditAction.indexOf("::remove") < 0) {
	        //CID 0641 //2010.11.06 //LocalResources
		    alert(InfoJet_LocalResources["CorrectFirstMessage"]);
			return;
		}
	}
	InfoJet_RefreshContext( placeholder );
	//CID 0293 //2009.05.28 //Begin
	if( xmlToEditAction == "xTextList::insert" ){
		var span = InfoJet_GetPreviousElement( placeholder );
		if( span != null ){
			var ol = InfoJet_GetFirstChild( span );
			if( ol != null ){
				var li = InfoJet_GetLastChild( ol );
				if( li != null ){
					var input = InfoJet_GetFirstChild( li );
					if( input != null ){
						InfoJet_RefreshContext( input );
					}
				}
			}
		}
	}
	//CID 0293 //2009.05.28 //End
	InfoJet_MoveProgress2ControlPosition( placeholder );
	document.getElementById( "xdoc_param_xml_to_edit_name" ).value = xmlToEditName;
	document.getElementById( "xdoc_param_xml_to_edit_action" ).value = xmlToEditAction;
	document.getElementById( "xdoc_param_command" ).value = "Update_XmlToEdit";
	InfoJet_Submit();
}

function InfoJet_OnPlaceholderKeydown( event, placeholder ){
	if(event.keyCode==13){
		InfoJet_OnPlaceholderClick( event, placeholder );
	}
}

function InfoJet_DoXmlToEditAction( itemId , xmlToEditName , xmlToEditAction ){
	var source = document.getElementById( itemId );
	if( InfoJet_CheckClickFrequently( source ) ){
		return;
	}
	InfoJet_MoveProgress2ControlPosition( source );
	if( (!InfoJet_IsViewValid()) && InfoJet_IsIdInArray( xmlToEditName , "xdoc_data_valid_view_xmltoedit_list" ) ){
	    if (xmlToEditAction.indexOf("::remove") < 0) {
	        //CID 0641 //2010.11.06 //LocalResources
		    alert(InfoJet_LocalResources["CorrectFirstMessage"]);
			return;
		}
	}
	var contextIds = new Array();
	if( itemId == null ){
		contextIds[ contextIds.length ] = document.getElementById( "xdoc_data_root_element_id" ).innerHTML;
	}else{
		InfoJet_GetMenuContextIds( contextIds , source );
	}
	var contextIdArray = "";
	for( var i = 0 ; i < contextIds.length ; i ++ ){
		contextIdArray += contextIds[ i ];
		if( i < contextIds.length - 1 ){
			contextIdArray += ";";
		}
	}
	document.getElementById( "xdoc_param_context_id_array" ).value = contextIdArray;
	document.getElementById( "xdoc_param_xml_to_edit_name" ).value = xmlToEditName;
	document.getElementById( "xdoc_param_xml_to_edit_action" ).value = xmlToEditAction;
	document.getElementById( "xdoc_param_command" ).value = "Update_XmlToEdit";
	InfoJet_Submit();
}

function InfoJet_DoSwitchView( viewId ){
	//CID 0262 //2009.03.26 //Begin
	if( InfoJet_ViewSwitchValidation ){
	    if (!InfoJet_IsViewValid()) {
	        //CID 0641 //2010.11.06 //LocalResources
		    alert(InfoJet_LocalResources["CorrectFirstMessage"]);
			return;
		}
	}
	//CID 0262 //2009.03.26 //End
	//CID 0346 //2009.09.14 //Begin
	InfoJet_FocusControlId = null;
	//CID 0346 //2009.09.14 //End
	InfoJet_MoveProgress2CentralPosition();
	document.getElementById( "xdoc_param_view_id" ).value = viewId;
	document.getElementById( "xdoc_param_command" ).value = "Update_View";
	InfoJet_Submit();
}

function InfoJet_DoNew( source ){
    InfoJet_MoveProgress2ControlPosition(source);
    //CID 0641 //2010.11.16 //LocalResources
	if (confirm(InfoJet_LocalResources["DeleteAllMessage"])) {
		//CID 0291 //2009.05.31 //Begin
		InfoJet_FocusControlId = source.id;
		//CID 0291 //2009.05.31 //End
		document.getElementById( "xdoc_param_command" ).value = "Update_New";
		InfoJet_Submit();
	}
}

function InfoJet_DoQuery( source ){
	InfoJet_MoveProgress2ControlPosition( source );
	//CID 0291 //2009.05.31 //Begin
	InfoJet_FocusControlId = source.id;
	//CID 0291 //2009.05.31 //End
	document.getElementById( "xdoc_param_command" ).value = "Update_Query";
	InfoJet_Submit();
}

function InfoJet_DoQueryDirect(){
	document.getElementById( "xdoc_param_command" ).value = "Update_Query";
	InfoJet_Submit();
}

function InfoJet_DoRefresh( source ){
	InfoJet_MoveProgress2ControlPosition( source );
	document.getElementById( "xdoc_param_command" ).value = "Update_Refresh";
	var auxDom = source.getAttribute( InfoJet_XdPrefix + "auxDom" );
	if( auxDom == null ){ auxDom = ""; }
	//CID 0291 //2009.05.31 //Begin
	InfoJet_FocusControlId = source.id;
	//CID 0291 //2009.05.31 //End
	document.getElementById( "xdoc_param_auxdom" ).value = auxDom;
	InfoJet_Submit();
}

function InfoJet_DoSubmit( source ){
	InfoJet_MoveProgress2ControlPosition( source );
	if (InfoJet_ValidSubmit && (!InfoJet_IsValid()) && (!InfoJet_NoValidation)) {
	    //CID 0641 //2010.11.06 //LocalResources
	    alert(InfoJet_LocalResources["CorrectFirstMessage"]);
		return;
	}
	//CID 0263 //2009.03.31 //Begin
	if( InfoJet_IsButton( source ) ){
		var ctrlId = source.getAttribute( InfoJet_XdPrefix + "CtrlId" );
		document.getElementById( "xdoc_param_button" ).value = ctrlId;
		document.getElementById( "xdoc_param_button_source" ).value = InfoJet_GetInnerMostContextId( source );
	}
	//CID 0263 //2009.03.31 //End
	//CID 0291 //2009.05.31 //Begin
	InfoJet_FocusControlId = source.id;
	//CID 0291 //2009.05.31 //End
	document.getElementById( "xdoc_param_command" ).value = "Update_Submit";
	InfoJet_Submit();
}

function InfoJet_DoSubmitDirect(){
	document.getElementById( "xdoc_param_command" ).value = "Update_Submit";
	InfoJet_Submit();
}

//CID 0935 //2011.06.01 //Begin
function InfoJet_DefaultSubmit() {
    if (InfoJet_ValidSubmit && (!InfoJet_IsValid()) && (!InfoJet_NoValidation)) {
        alert(InfoJet_LocalResources["CorrectFirstMessage"]);
        return;
    }
    document.getElementById("xdoc_param_command").value = "Update_Submit";
    InfoJet_Submit();
}
//CID 0935 //2011.06.01 //End

function InfoJet_OpenExportedMHT( source ){
	InfoJet_MoveProgress2ControlPosition( source );
	document.getElementById( "xdoc_param_command" ).value = "Update_Button";
	document.getElementById( "xdoc_param_button" ).value = "Inner_Export_Mht_Button";
	document.getElementById( "xdoc_param_button_source" ).value = "";
	InfoJet_Submit();
}

//CID 0335 //2009.06.22 //Begin
function InfoJet_OpenExportedHTML4FF( source ){
	InfoJet_MoveProgress2ControlPosition( source );
	document.getElementById( "xdoc_param_command" ).value = "Update_Button";
	document.getElementById( "xdoc_param_button" ).value = "Inner_Export_Html4FF_Button";
	document.getElementById( "xdoc_param_button_source" ).value = "";
	InfoJet_Submit();
}
//CID 0335 //2009.06.22 //End

//CID 0335 //2009.06.22 //Begin
function InfoJet_OpenPrintableVersion( source ){
	if( InfoJet_IsIE() ){
		InfoJet_OpenExportedMHT( source );
	}else{
		InfoJet_OpenExportedHTML4FF( source );
	}
}
//CID 0335 //2009.06.22 //End

//CID 0735 //2010.12.19 //Begin
function InfoJet_CheckOnClickTable(source, ctrlId) {
    var viewId = document.getElementById("xdoc_param_view_id").value;
    var clickId = viewId + "#" + ctrlId;
    if (InfoJet_OnClickTable != null) {
        for (var id in InfoJet_OnClickTable) {
            if (id == clickId) {
                var sender = { control: source, id: ctrlId };
                var args = {};
                return InfoJet_OnClickTable[clickId].call(null, sender, args);
            }
        }
    }
    return true;
}
//CID 0735 //2010.12.19 //End

function InfoJet_DoButton( source ){
	//CID 0347 //2009.07.19 //Begin
	source.setAttribute( "isMouseDown", "false" );
	//CID 0347 //2009.07.19 //End
	if( InfoJet_CheckClickFrequently( source ) ){
		return;
	}
	
	InfoJet_MoveProgress2ControlPosition( source );
	var ctrlId = source.getAttribute( InfoJet_XdPrefix + "CtrlId" );
	if( ctrlId == null ){ 
		return;
	}
	if ((!InfoJet_IsViewValid()) && InfoJet_IsIdInArray(ctrlId, "xdoc_data_valid_view_button_list")) {
	    //CID 0641 //2010.11.06 //LocalResources
	    alert(InfoJet_LocalResources["CorrectFirstMessage"]);
		return;
	}
	if( (!InfoJet_IsValid()) && InfoJet_IsFuncDefined( "OnValidFormButton_" + ctrlId ) ){
		eval( "OnValidFormButton_" + ctrlId + "();" );
		return;
    }
    //CID 0735 //2010.12.19 //Begin
    if (!InfoJet_CheckOnClickTable(source, ctrlId)) {
        return;
    }
    //CID 0735 //2010.12.19 //End
	if (InfoJet_IsFuncDefined("OnClientScriptButton_" + ctrlId)) {
	    if (!eval("OnClientScriptButton_" + ctrlId + "();")) {
	        return;
	    }
	}
	var isSubmitButton = source.getAttribute( "submit_button" );
	if( isSubmitButton != null && isSubmitButton == "true" ){
	    if (InfoJet_ValidSubmit && (!InfoJet_IsValid()) && (!InfoJet_NoValidation)) {
	        //CID 0641 //2010.11.06 //LocalResources
		    alert(InfoJet_LocalResources["CorrectFirstMessage"]);
			return;
		}
	}
	//CID 0291 //2009.05.31 //Begin
	InfoJet_FocusControlId = source.id;
	//CID 0291 //2009.05.31 //End
	document.getElementById( "xdoc_param_command" ).value = "Update_Button";
	document.getElementById( "xdoc_param_button" ).value = ctrlId;
	document.getElementById( "xdoc_param_button_source" ).value = InfoJet_GetInnerMostContextId( source );
	InfoJet_Submit();
}

function InfoJet_DoButtonDirect( ctrlId, buttonSource )
{
	InfoJet_MoveProgress2CentralPosition();
	document.getElementById( "xdoc_param_command" ).value = "Update_Button";
	document.getElementById( "xdoc_param_button" ).value = ctrlId;
	document.getElementById( "xdoc_param_button_source" ).value = buttonSource;
	InfoJet_Submit();
}

function InfoJet_RebuildByCommand( command ){
	if( InfoJet_ShowProgress && InfoJet_Progress == null ){ //InfoJet_Init() not called.
		InfoJet_FuncAfterInit = "InfoJet_MoveProgress2CentralPosition(); InfoJet_StartProgress();";
	}
	InfoJet_MoveProgress2CentralPosition();
	document.getElementById( "xdoc_param_command" ).value = "Update_Rebuild";
	document.getElementById( "xdoc_param_rebuild_command" ).value = command;
	//CID 0298 //2009.06.01 //Begin
	if( InfoJet_AjaxBracket != null ){
		InfoJet_UpdateAjaxBracket();
	}
	//CID 0298 //2009.06.01 //End
	InfoJet_Submit();
}

//CID 0087 //2008.08.05 //Begin
function InfoJet_OnPostbackStart(){
	if( InfoJet_IsFuncDefined( "InfoJetCustom_OnPostbackStart" ) ){
		eval( "InfoJetCustom_OnPostbackStart();" );
	}
}
//CID 0087 //2008.08.05 //End

//CID 0087 //2008.08.05 //Begin
function InfoJet_OnPostbackEnd() {
    if( InfoJet_IsFuncDefined( "InfoJetCustom_OnPostbackEnd" ) ){
		eval( "InfoJetCustom_OnPostbackEnd();" );
	}
}
//CID 0087 //2008.08.05 //End

//CID 0499 //2010.03.18 //targetForm
function InfoJet_Submit( targetForm ){
	//CID 0296 //2009.06.23 //Begin
	InfoJet_NewStructureNodeId = null;
	//CID 0296 //2009.06.23 //End
	
	InfoJet_Postbacking = 1;
	InfoJet_StartProgress();
	
	//CID 0087 //2008.08.05 //Begin
	InfoJet_OnPostbackStart();
	//CID 0087 //2008.08.05 //End
	//CID 0291 //2009.05.31 //InfoJet_UseAjax
	if( InfoJet_UseAjax ){
		//CID 0499 //2010.03.18 //targetForm
		InfoJet_AJAXRequest( targetForm );
	}else{
		//test MultipleMessages.xsn
		var form = null;
		//CID 0499 //2010.03.18 //Begin
		if( typeof(targetForm) != "undefined" ){
			form = targetForm;
		}else{
			form = document.getElementById( "xdoc_form" );
		}
		//CID 0499 //2010.03.18 //End
		var serviceAction = document.getElementById( "xdoc_param_action" ).value;
		var frameDocument = InfoJet_GetFrameDocument( "xdoc_frame" );
		if( frameDocument.forms.length > 0 && frameDocument.forms[0].name != "xdoc_service" ){
			//CID 0332 //2009.08.12 //Begin
			frameDocument.forms[0].action = serviceAction;
			//CID 0332 //2009.08.12 //End
			//InfoJet EditPart,submit in the webpart form.
			frameDocument.forms[0].innerHTML = form.innerHTML;
			frameDocument.forms[0].submit();
		}else{
		    var content = "<html><head><meta http-equiv='Content-Type' content='text/html; charset=utf-8'></meta></head>";
			content += "<body><form id='xdoc_service' name='xdoc_service' method='post' action='" + serviceAction + "'>";
			content += "</form></body></html>";
			frameDocument.write( content );
			frameDocument.forms[0].innerHTML = form.innerHTML;
			frameDocument.forms[0].submit();
		}
	}
}

//CID 1422 //2012.10.31 //Begin
function InfoJet_PostbackOnControl(control) {
    InfoJet_CheckOldValueState(control);
    InfoJet_MoveProgress2ControlPosition(control);
    InfoJet_AJAXonField(control);
}
//CID 1422 //2012.10.31 //End

function InfoJet_AJAXonField( control ){
	if( InfoJet_NoPostback ){
		return;
	}
	InfoJet_Postbacking = 1;
	InfoJet_StartProgress();
	
	//CID 0077 //2008.08.01 //Begin
	InfoJet_OnPostbackStart();
	//CID 0077 //2008.08.01 //End
	
	document.getElementById( "xdoc_param_update_id" ).value = control.id;
	document.getElementById( "xdoc_param_update_format" ).value = control.getAttribute( InfoJet_XdPrefix + "datafmt" );
	//CID 0290 //2009.05.26 //Begin
	document.getElementById( "xdoc_param_command" ).value = "Update_Refresh";
	//CID 0290 //2009.05.26 //End
	//CID 0255 //2009.05.18 //Begin
	InfoJet_FocusControlId = control.id;
	//CID 0255 //2009.05.18 //End
	InfoJet_AJAXRequest();
}

//CID 0610 //2010.06.05 //Begin
function InfoJet_BuildAJAXPost(form) {
    //CID 0612 //2010.06.10 //Begin
    var postBuilder = new Array();
    //CID 0612 //2010.06.10 //End
    //CID 0278 //2009.05.02 //childNodes
    for (var i = 0; i < form.childNodes.length; i++) {
        var field = form.childNodes[i];
        if (field.nodeType == 1) {
            if (field.name) {
                //CID 0612 //2010.06.10 //Begin
                postBuilder.push(field.name + "=" + encodeURIComponent(field.value));
                //CID 0612 //2010.06.10 //End
            }
        }
    }
    //CID 0612 //2010.06.10 //Begin
    var post = postBuilder.join("&");
    //CID 0612 //2010.06.10 //End
    return post;
}
//CID 0610 //2010.06.05 //End

//CID 0499 //2010.03.18 //targetForm
function InfoJet_AJAXRequest(targetForm) {
    //CID 0296 //2009.06.23 //Begin
	InfoJet_NewStructureNodeId = null;
	//CID 0296 //2009.06.23 //End
	var form = null;
	//CID 0499 //2010.03.18 //Begin
	if( typeof(targetForm) != "undefined" ){
		form = targetForm;
	}else{
		form = document.getElementById( "xdoc_form" );
	}
	//CID 0499 //2010.03.18 //End
	//CID 0610 //2010.06.05 //Begin
    var post = InfoJet_BuildAJAXPost(form);
	//CID 0610 //2010.06.05 //End
	var serviceAction = document.getElementById( "xdoc_param_action" ).value;
	//CID 0381 //2009.08.05 //Begin
	if( InfoJet_XHR == null ){
		InfoJet_XHR = InfoJet_AJAXCreateRequest();
	}
	//CID 0381 //2009.08.05 //End
	//CID 0134 //2008.10.05 //Begin
	//CID 0291 //2009.05.31 //isAsync
	//CID 0291 //2009.05.31 //true
	InfoJet_XHR.open("POST", serviceAction, true);	//CID 0133 //2008.10.05 //open
	//CID 0381 //2009.08.05 //Begin
	InfoJet_XHR.onreadystatechange = InfoJet_AJAXResponse;
	//CID 0381 //2009.08.05 //End
	//CID 0134 //2008.10.05 //End
	InfoJet_XHR.setRequestHeader("Content-Length",post.length);
	InfoJet_XHR.setRequestHeader("CONTENT-TYPE","application/x-www-form-urlencoded");
	InfoJet_XHR.send(post);							//CID 0133 //2008.10.05 //send
}

function InfoJet_AJAXResponse() {
    if(InfoJet_XHR.readyState == 4){
		if(InfoJet_XHR.status == 200){
		    var responseText = InfoJet_XHR.responseText;
			if( InfoJet_AjaxBracket != null && InfoJet_AjaxBracket.length > 0 ){
				var ajaxBracket = "--" + InfoJet_AjaxBracket + "--";
				var ajaxBracketIndex = responseText.indexOf( ajaxBracket );
				var ajaxBracketStart = ajaxBracketIndex + ajaxBracket.length;
				var ajaxBracketEnd = responseText.indexOf( ajaxBracket, ajaxBracketStart );
				responseText = responseText.substr( ajaxBracketStart, ajaxBracketEnd - ajaxBracketStart );
			}
			try{
				if( responseText.indexOf( "InfoJetSoft.Service." ) >= 0 ){
					//CID 0332 //2009.08.07 //Begin
					var errorStart = responseText.indexOf( "<!--InfoJetSoft.Service.PostbackError-->" );
					if( errorStart >= 0 ){
						var errorMessage = null;
						var messageKey = "<!--InfoJetSoft.Service.ErrorMessage(";
						var messageStart = responseText.indexOf( messageKey );
						if( messageStart >= 0 ){
							var messageEnd = responseText.indexOf( ")-->", messageStart );
							messageStart = messageStart + messageKey.length;
							errorMessage = responseText.substr( messageStart, messageEnd - messageStart );
						}
						InfoJet_OnPostbackError( errorMessage );
						return;
					}
					//CID 0332 //2009.08.07 //End
					//CID 0357 //2009.07.06 //Begin
					var reloginStart = responseText.indexOf( "<!--InfoJetSoft.Service.Relogin-->" );
					if( reloginStart >= 0 ){
						if( typeof(InfoJetCustom_ReloginAfterAJAXPostback) != "undefined" ){
							InfoJetCustom_ReloginAfterAJAXPostback();
						}else{
							alert("InfoJetCustom_ReloginAfterAJAXPostback() is not defined.");
						}
						return;
					}
					//CID 0357 //2009.07.06 //End
					var loginUrlKey = "InfoJetSoft.Service.LoginUrl(";
					var loginUrlStart = responseText.indexOf( loginUrlKey );
					if( loginUrlStart >= 0 ){
						var loginUrlEnd = responseText.indexOf( ")", loginUrlStart );
						loginUrlStart = loginUrlStart + loginUrlKey.length;
						var loginUrl = responseText.substr( loginUrlStart, loginUrlEnd - loginUrlStart );
						if( typeof(InfoJetCustom_BeforeGotoLoginPage) != "undefined" ){
							InfoJetCustom_BeforeGotoLoginPage();
						}
						window.location = loginUrl;
						return;
					}
				}
				//CID 0135 //2008.10.05 //Begin
				if( responseText.indexOf( "----$InfoJet_Separator$----" ) > 0 ){
					var fragments = responseText.split( "----$InfoJet_Separator$----" );
					var viewHtml = fragments[0];
					var formHtml = fragments[1];
					var dataHtml = fragments[2];
					responseText = fragments[3];
					InfoJet_ReloadFormVars( viewHtml, formHtml, dataHtml );
					eval(responseText);
				//CID 0135 //2008.10.05 //End
				}else{
					eval( responseText );
				}
			}catch( e ){
				var startErrorMessageIndex = responseText.indexOf( "--InfoJet_Custom_Error_Message--" );
				var endErrorMessageIndex = responseText.lastIndexOf( "--InfoJet_Custom_Error_Message--" );
				if( startErrorMessageIndex >= 0 && endErrorMessageIndex > startErrorMessageIndex ){
					startErrorMessageIndex = startErrorMessageIndex + "--InfoJet_Custom_Error_Message--".length;
					var errorMessage = responseText.substr( startErrorMessageIndex, endErrorMessageIndex - startErrorMessageIndex );
					errorMessage = errorMessage.replace(/(^\s*)|(\s*$)/g, "");
					alert( errorMessage );
				}else{
					if( responseText.indexOf( "var " ) != 0 && responseText.indexOf( "InfoJet_" ) != 0 ){
					    //CID 0878 //2011.04.23 //Begin
					    if (responseText.indexOf("[InfoJetService.MC01]") == 0) {
					        alert("Form template is not avaliable. Please try again later or contact your system administrator.");
					        InfoJet_StopProgress();
					        InfoJet_Postbacking = 0;
					        InfoJet_OnPostbackEnd();
					        InfoJet_UndoOldValueState();
					    } else {
					        alert(responseText);
					    }
					    //CID 0878 //2011.04.23 //End
					} else {
		                alert( e.message );
					}
				}
			}
		}else{
			if( InfoJet_IsFuncDefined( "InfoJetCustom_OnAjaxError" ) ){
				InfoJetCustom_OnAjaxError( InfoJet_XHR );
            } else {
                //CID 0713 //2010.11.27 //if
                if (!InfoJet_CheckNetworkError()) {
                    //CID 0332 //2009.08.07 //Begin
                    InfoJet_OnPostbackError("Error(" + InfoJet_XHR.status + ") occurred.");
                    //CID 0332 //2009.08.07 //End
                }
			}
		}
    }
}

//CID 0713 //2010.11.27 //Begin
var InfoJet_NetworkErrorCodes = [0, 1223, 12002, 12029, 12030, 12031, 12152];
//CID 0713 //2010.11.27 //End

//CID 0713 //2010.11.27 //Begin
function InfoJet_CheckNetworkError() {
    for (var i = 0; i < InfoJet_NetworkErrorCodes.length; i++) {
        if (InfoJet_XHR.status == InfoJet_NetworkErrorCodes[i]) {
            var message = "";
            if (InfoJet_OldValueState != null && InfoJet_OldValueState.valid) {
                message = "Undoing entry due to Network Error(" + InfoJet_XHR.status + "), please check your network connection.";
            } else {
                message = "Network Error(" + InfoJet_XHR.status + ") occurred, please check your network connection";
            }
            alert(message);
            InfoJet_StopProgress();
            InfoJet_Postbacking = 0;
            InfoJet_OnPostbackEnd();
            InfoJet_UndoOldValueState();
            return true;
        }
    }
    return false;
}
//CID 0713 //2010.11.27 //End

//CID 0332 //2009.08.07 //Begin
function InfoJet_OnPostbackError( detailedMessage ){
	if( InfoJet_Postbacking > 0 ){
	    if (InfoJet_IsFuncDefined("InfoJetCustom_OnPostbackError")) {
	        InfoJetCustom_OnPostbackError(detailedMessage);
	    } else {
	        alert(detailedMessage);
	    }
	}
}
//CID 0332 //2009.08.07 //End

function InfoJet_AJAXCreateRequest(){
	var xhr = null;
	if( document.all ){
		try {
			xhr = new ActiveXObject("Msxml2.XMLHTTP");
		}catch (e){
			try {
				xhr = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e2) {
				xhr = null;
			}
		}
	}else{
		//CID 0133 //2008.10.05 //Begin
		xhr = new XMLHttpRequest();
		//CID 0133 //2008.10.05 //End
	}
	if( xhr == null ){
		alert("Failed: Cannot create XMLHttpRequest.");
	}
	return xhr;
}

function InfoJet_UpdateAjaxBracket(){
	var ajaxBracket = document.getElementById( "xdoc_param_ajax_bracket" );
	if( ajaxBracket != null ){
		ajaxBracket.value = InfoJet_AjaxBracket;
	}
}

//0379 //2009.08.13 //Begin
function InfoJet_OnCanvasContextMenu( event ){
	return false;
}
//0379 //2009.08.13 //End

//0880 //2011.04.22 //Begin
function InfoJet_Ping() {
    if (InfoJet_PingParameter != null) {
        var serviceAction = document.getElementById("xdoc_param_action").value;
        if (InfoJet_PingXHR == null) {
            InfoJet_PingXHR = InfoJet_AJAXCreateRequest();
        }
        var post = InfoJet_PingParameter;
        InfoJet_PingXHR.open("POST", serviceAction, true);
        InfoJet_PingXHR.setRequestHeader("Content-Length", post.length);
        InfoJet_PingXHR.setRequestHeader("CONTENT-TYPE", "application/x-www-form-urlencoded");
        InfoJet_PingXHR.send(post);
        window.setTimeout("InfoJet_Ping();", InfoJet_PingInterval);
    }
}
//0880 //2011.04.27 //End

function InfoJet_BuildProgress(){
	if( InfoJet_ShowProgress && InfoJet_Progress == null ){
		var progressHtml = "<div id='xdoc_progress' style='visibility:hidden;position:absolute;z-index:100'><img src='" + InfoJet_WebContext + "images/infojet_progress_circle.gif'></div>";
		//CID 0017 //2008.06.16 //Begin
		InfoJet_InsertAdjacentHTMLBeforeEnd( InfoJet_Container, progressHtml );
		//CID 0017 //2008.06.16 //End
		InfoJet_Progress = document.getElementById( "xdoc_progress" );
	}
	//CID 0300 //2009.06.04 //if
	if( InfoJet_Canvas == null ){
		//CID 0255 //2009.05.25 //Begin
		//CID 0077 //2008.08.03 //Begin
		var canvasHtml = null;
		//0379 //2009.08.13 //Begin
		if( InfoJet_IsCanvasTranparent ){
			canvasHtml = "<div id='xdoc_canvas' oncontextmenu='return InfoJet_OnCanvasContextMenu(event);' style='width:0px;height:0px;position:absolute;z-index:99;background:#FFFFFF;filter:alpha(opacity=0);-moz-opacity:0;opacity:0;padding:0px;margin:0px;'>&nbsp;</div>";
		}else{
			canvasHtml = "<div id='xdoc_canvas' oncontextmenu='return InfoJet_OnCanvasContextMenu(event);' style='width:0px;height:0px;position:absolute;z-index:99;background:#FFFFFF;filter:alpha(opacity=50);-moz-opacity:0.5;opacity:0.5;padding:0px;margin:0px;'>&nbsp;</div>";
		}
		//0379 //2009.08.13 //End
		InfoJet_InsertAdjacentHTMLBeforeEnd( InfoJet_Container, canvasHtml );
		InfoJet_Canvas = document.getElementById( "xdoc_canvas" );
		//CID 0077 //2008.08.03 //End
		//CID 0255 //2009.05.25 //End
		//CID 0380 //2009.09.22 //Begin
		if (!InfoJet_IsIE()) {
		    var focusHolderHtml = "<input type='text' id='xdoc_focus_holder' style='width:0px;height:0px;position:absolute;display:none;'></input>";
			InfoJet_InsertAdjacentHTMLBeforeEnd( document.body, focusHolderHtml );
			InfoJet_FocusHolder = document.getElementById("xdoc_focus_holder");
		}
		//CID 0380 //2009.09.22 //End
	}
}

function InfoJet_MoveProgress2Position( left, top ){
	if( InfoJet_ShowProgress && InfoJet_Progress != null ){
		InfoJet_Progress.style.left = left;
		InfoJet_Progress.style.top = top;
	}
}

function InfoJet_MoveProgress2CentralPosition(){
	if( InfoJet_ShowProgress && InfoJet_Progress != null ){
		InfoJet_Progress.style.left = document.body.clientWidth / 2 - InfoJet_Progress.offsetWidth + document.body.scrollLeft;
		InfoJet_Progress.style.top = document.body.clientHeight / 2 - InfoJet_Progress.offsetHeight + document.body.scrollTop;
	}
}

function InfoJet_MoveProgress2ControlPosition( control ){
	if( InfoJet_ShowProgress && InfoJet_Progress != null ){
		if( control ){
			var xAlgin = control.offsetWidth / 2 + InfoJet_Progress.offsetWidth / 2;
			var yAlgin = control.offsetHeight / 2 + InfoJet_Progress.offsetHeight / 2;
			try{
				var pos = InfoJet_GetPos( control );
				//CID 0501 //2010.01.23 //Begin
				if( pos == null ){
					return;
				}
				//CID 0501 //2010.01.23 //End
				InfoJet_Progress.style.left = pos.left + control.offsetWidth - xAlgin;
				InfoJet_Progress.style.top = pos.top + control.offsetHeight - yAlgin;
			}catch( e ){
				InfoJet_MoveProgress2CentralPosition();
			}
		}else{
			InfoJet_MoveProgress2CentralPosition();
		}
	}
}

function InfoJet_MoveProgress2MousePosition( event ){
	if( InfoJet_ShowProgress && InfoJet_Progress != null ){
		if( event ){
			InfoJet_Progress.style.left = event.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
			InfoJet_Progress.style.top = event.clientY + document.body.scrollTop + document.documentElement.scrollTop;
		}else{
			InfoJet_MoveProgress2CentralPosition();
		}
	}
}

function InfoJet_StartProgress(){
	//CID 0255 //2009.05.25 //Begin
	if( InfoJet_Progress != null ){
		InfoJet_Progress.style.visibility = "visible";
	}
	//CID 0077 //2008.08.03 //Begin
	if( InfoJet_Canvas != null ){
		var xdoc = document.getElementById( "xdoc" );
		if( xdoc != null ){
			//Enlarge the modal screen.
			var pos = InfoJet_GetPos( xdoc );
			//CID 0501 //2010.01.23 //Begin
			if( pos == null ){
				return;
			}
			//CID 0501 //2010.01.23 //End
			InfoJet_Canvas.style.left = pos.left;
			InfoJet_Canvas.style.top = pos.top;
			InfoJet_Canvas.style.width = xdoc.offsetWidth;
			InfoJet_Canvas.style.height = xdoc.offsetHeight;
		}
	}
	//CID 0077 //2008.08.03 //End
	//CID 0255 //2009.05.25 //End
}

function InfoJet_StopProgress(){
	//CID 0255 //2009.05.25 //Begin
	if( InfoJet_Progress != null ){
		InfoJet_Progress.style.visibility = "hidden";
	}
	//CID 0077 //2008.08.03 //Begin
	if( InfoJet_Canvas != null ){
		InfoJet_Canvas.style.width = "0px";
		InfoJet_Canvas.style.height = "0px";
	}
	//CID 0077 //2008.08.03 //End
	//CID 0255 //2009.05.25 //End
}

function InfoJet_SubmitToHost( source ){
    if (InfoJet_ValidSubmit && (!InfoJet_IsValid()) && (!InfoJet_NoValidation)) {
        //CID 0641 //2010.11.06 //LocalResources
	    alert(InfoJet_LocalResources["CorrectFirstMessage"]);
		return;
	}
		
	if( InfoJet_IsFuncDefined( "InfoJetCustom_SubmitToHost" ) ){
		eval( "InfoJetCustom_SubmitToHost();" );
	}else{
		var form = null;
		var element = InfoJet_GetParent( source );
		while( element != null ){
			if( element.tagName.toLowerCase() == "form" ){
				form = element;
				break;
			}
			element = InfoJet_GetParent( element );
		}
		if( form != null ){
			form.submit();
		}
	}
}

function InfoJet_Try2CloseWindow(isPromptToSaveChanges) {
    //CID 1546 //2013.01.14 //Begin
    var context = InfoBus_GetIFrameContext();
    if (context != null)
    {
        window.parent.InfoBus_CustomTry2CloseWindow(isPromptToSaveChanges);
        return;
    }
    //CID 1546 //2013.01.14 //End
	var formWindow = null;
	//CID 0291 //2009.05.31 //InfoJet_UseAjax
	if( InfoJet_UseAjax ){
		formWindow = window;
	}else{
		formWindow = window.parent;
	}
	if( isPromptToSaveChanges ){
	    if (formWindow.InfoJet_Changed) {
	        //CID 0641 //2010.11.06 //LocalResources
	        if (formWindow.confirm(InfoJet_LocalResources["CloseAnywayMessage"])) {
				InfoJet_CloseWindow( formWindow );
			}
		}else{
			InfoJet_CloseWindow( formWindow );
		}
	}else{
		InfoJet_CloseWindow( formWindow );
	}
}

function InfoJet_CloseWindow( formWindow ){
	if( InfoJet_IsFuncDefined( "InfoJetCustom_CloseWindow" ) ){
		InfoJetCustom_CloseWindow( formWindow );
	}else{
		//CID 0458 //2009.11.11 //Begin
		if( InfoJet_IsIE() ){
			if( InfoJet_IsIE7() ){ //CID 0515 //2010.03.24 //IsIE7
				formWindow.open('', '_parent', '');
				formWindow.close();
			}else{
				formWindow.opener = null;
				formWindow.close();
			}
		}else{
			formWindow.close();
		}
        //CID 0458 //2009.11.11 //End
	}
}

function InfoJet_IsIdInIds( id , ids ){
	for( var i = 0 ; i < ids.length ; i ++ ){
		if( ids[ i ] == id ){
			return true;
		}
	}
	return false;
}

//CID 0400 //2009.11.24 //Begin
function InfoJet_FocusFirstControlAutomatically(){
	if( !InfoJet_IsInited() ){
		InfoJet_FocusFirstControlAfterInited = true;
		return;
	}
    try{
		var xdocView = document.getElementById( "xdoc_view" );
        if( xdocView != null ){
            var firstFocusableControl = InfoJet_FindFocusableControlInElement( xdocView );
            if (firstFocusableControl != null) {
                //CID 1369 //2012.10.07 //Comment if
				//if( InfoJet_IsIE() || InfoJet_IsFireFox() ){
					firstFocusableControl.setAttribute( "noTextSelection", "true" );
					//CID 0548 //2010.05.13 //try catch
					window.setTimeout(function(){ try{ firstFocusableControl.focus(); }catch(e){} }, 100);
				//}
			}
        }
    }catch(e){}
}
//CID 0400 //2009.11.24 //Begin

//CID 0450 //2009.11.05 //Begin
function InfoJet_OnOpenView(isFirstView){
	if( typeof(InfoJetCustom_OnOpenView) != "undefined" ){
		eval( "InfoJetCustom_OnOpenView( " + isFirstView + " );" );
	}else{
		if(!isFirstView){
			if( InfoJet_ScrollFollowUpFormViewIntoView ){
				var xdoc = document.getElementById( "xdoc" );
				xdoc.scrollIntoView();
			}else{
				window.scroll(0,0);
			}
		}
		//CID 0400 //2009.11.24 //Begin
		InfoJet_FocusFirstControlAutomatically();
		//CID 0400 //2009.11.24 //End
	}
}
//CID 0450 //2009.11.05 //End

function InfoJet_SelectText( fieldId, controlId ){
	var field = document.getElementById( fieldId );
	if( field != null ){
		//CID 0400 //2009.12.08 //Begin
		field.scrollIntoView();
		window.setTimeout(function(){ field.focus(); }, 100);
		//CID 0400 //2009.12.08 //End
	}
}

function InfoJet_RefreshXmlToEditItem( source , isSetItemId ){
	var focusMenuArrow = document.getElementById( "xdoc_menu_focus_arrow" );
	if( focusMenuArrow == null ){
		return null;
	}
	var itemXmlToEdits = InfoJet_GetItemXmlToEdits( source );
	if( itemXmlToEdits.xmlToEditNames.length > 0 ){
		var itemElement = itemXmlToEdits.itemElement;
		if( isSetItemId ){
			focusMenuArrow.setAttribute( "itemId" , InfoJet_GetElementId( itemElement ) );
			//itemHtmlId is used to hold the original html id of the element.
			//CID 0002 //2008.05.29 //Begin
			focusMenuArrow.setAttribute( "itemHtmlId", itemElement.id );
			//CID 0002 //2008.05.29 //End
		}
		return itemElement;
	}else{
		if( isSetItemId ){
			focusMenuArrow.setAttribute( "itemId" , document.getElementById( "xdoc_data_root_element_id" ).innerHTML );
			//CID 0002 //2008.05.29 //Begin
			focusMenuArrow.setAttribute( "itemHtmlId", "xdoc_view" );
			//CID 0002 //2008.05.29 //End
		}
		return null;
	}
}

function InfoJet_GetItemXmlToEdits( source ){
	//CID 0286 //2009.05.11 //Begin
	if( InfoJet_XmlToEditItems == null ){
		var xmlToEditNames = document.getElementById( "xdoc_data_xmltoedit_name_array" ).innerHTML.split( ";" );
		var xmlToEditItems = new Array();
		for( var i = 0 ; i < xmlToEditNames.length ; i ++ ){
			var itemArrayField = document.getElementById( xmlToEditNames[ i ] + "_item" );
			if( itemArrayField != null ){
				var items = itemArrayField.innerHTML.split( ";" );
				var xmlToEditItem = new Object();
				xmlToEditItem.name = xmlToEditNames[ i ];
				xmlToEditItem.items = items;
				xmlToEditItems[ xmlToEditItems.length ] = xmlToEditItem;
			}
		}
		InfoJet_XmlToEditItems = xmlToEditItems;
	}
	//CID 0286 //2009.05.11 //End
	
	var itemXmlToEdits = new Object();
	itemXmlToEdits.xmlToEditNames = new Array();
	//CID 0286 //2009.05.11 //Begin
	InfoJet_GetItemElement( itemXmlToEdits , InfoJet_XmlToEditItems , source );
	//CID 0286 //2009.05.11 //End
	return itemXmlToEdits;
}

function InfoJet_GetItemElement( itemXmlToEdits , xmlToEditItems , source ){
	if( source == null || source.id == "xdoc_view" || source.tagName.toLowerCase() == "body" ){
		return;
	}
	for( var i = 0 ; i < xmlToEditItems.length ; i ++ ){
		var items = xmlToEditItems[ i ].items;
		for( var m = 0 ; m < items.length ; m ++ ){
			if( items[ m ] != "" ){
				if( InfoJet_GetElementId( source ) == items[ m ] ){
					itemXmlToEdits.xmlToEditNames[ itemXmlToEdits.xmlToEditNames.length ] = xmlToEditItems[ i ].name;
				}				
			}
		}
	}
	if( itemXmlToEdits.xmlToEditNames.length > 0 ){
		itemXmlToEdits.itemElement = source;
		return;
	}
	InfoJet_GetItemElement( itemXmlToEdits , xmlToEditItems , InfoJet_GetParent( source ) );
}

function InfoJet_OnKeyPress( event , control ){
	if( event.keyCode == 13 ){
		if( control.tagName.toLowerCase() == "textarea" ){
			var defaultRows = control.getAttribute( "default_rows" );
			if( defaultRows != null && defaultRows == "1" ){
				if( InfoJet_IsIE() ){
					event.returnValue = false;
				}else{
					event.preventDefault();
				}
			}
		}
	}
	if (InfoJet_IsTextControl(control)) {
	    var maxLength = InfoJet_GetTextControlMaxLength(control);
	    if (maxLength > 0) {
	        if (control.value.length >= maxLength) {
	            //CID 1019 //2011.09.20 //Begin
	            var ghosted = control.getAttribute( InfoJet_XdPrefix + "ghosted" );
	            if (ghosted == null || ghosted == "false") {
	                //CID 0874 //2011.04.23 //Begin
	                if (InfoJet_IsIE()) {
	                    event.returnValue = false;
	                } else {
	                    var keyCode = event.keyCode;
	                    if (!(keyCode == 37 || keyCode == 39 || keyCode == 8 || keyCode == 9)) {
	                        event.preventDefault();
	                    }
	                }
	                //CID 0874 //2011.05.01 //End
	            }
	            //CID 1019 //2011.09.20 //End
	        }
	    }
	    //CID 0829 //2011.03.08 //End
	}
}

//CID 0829 //2011.03.08 //Begin
function InfoJet_GetTextControlMaxLength(control) {
    var maxLength = control.getAttribute("textControlMaxLength");
    if (maxLength == null) {
        var found = false;
        var maxLengthList = document.getElementById("xdoc_data_max_length_list").innerHTML;
        if (maxLengthList.length > 0) {
            var maxLengthFields = maxLengthList.split(";");
            for (var i = 0; i < maxLengthFields.length; i++) {
                var idMaxLength = maxLengthFields[i].split(",");
                var id = idMaxLength[0];
                var maxLengthValue = idMaxLength[1];
                var controlId = InfoJet_GetElementId(control);
                if (controlId == id) {
                    maxLength = maxLengthValue;
                    control.setAttribute("textControlMaxLength", maxLength);
                    found = true;
                    break;
                }
            }
        }
        if (!found) {
            maxLength = "0";
            control.setAttribute("textControlMaxLength", maxLength);
        }
    }
    return parseInt(maxLength, 10);
}
//CID 0829 //2011.03.08 //End

function InfoJet_TrimByMaxLength(control) {
    //CID 0829 //2011.03.08 //Begin
    var maxLength = InfoJet_GetTextControlMaxLength(control);
    if (maxLength > 0) {
        if( control.value.length > maxLength ){
            //CID 0874 //2011.05.01 //Begin
            control.value = control.value.substring(0, maxLength);
            //CID 0874 //2011.05.01 //End
        }
    }
    //CID 0829 //2011.03.08 //End
}

//CID 0249 //2009.03.15 //Begin
function InfoJet_IsComboxPostback( control ){
	var logicTags = control.getAttribute( "logic_tags" );
	if( logicTags != null && logicTags.length > 0 ){
		return true;
	}
	var isServerControl = control.getAttribute( "server_control" );
	if( isServerControl == null || isServerControl == "yes" ){
		return true;
	}
	//CID 0500 //2010.07.29 //Begin
	var schemaType = InfoJet_GetSchemaType(control);
	//CID 0500 //2010.07.29 //End
	if( schemaType != null && schemaType == "unknown" ){
		return true;
	}
	return false;
}
//CID 0249 //2009.03.15 //End

function InfoJet_OnKeyDown(event, control) {
    event = InfoJet_GetEvent( event );
	//CID 0249 //2009.03.15 //Begin
	if( event.keyCode == 40 ){
	    if (control.className != null && control.className.indexOf("ComboBoxTextField") > 0) {
	        //CID 0255 //2009.05.19 //InfoJet_GetNextElement( control )
	        var select = InfoJet_GetNextElement(control);
	        if (!InfoJet_IsComboxPostback(control)) {
	            select.size = select.options.length;
	            select.style.zIndex = 100;
	            var pos = InfoJet_GetPos(control);
	            //CID 0501 //2010.01.23 //Begin
	            if (pos == null) {
	                return;
	            }
	            //CID 0501 //2010.01.23 //End
	            select.style.top = pos.top + control.offsetHeight;
	            select.setAttribute("oldClip", select.style.clip);
	            select.style.clip = "rect(auto auto auto auto)";
	            var onchangeFunc = select.onchange;
	            select.setAttribute("onchangeFunc", onchangeFunc);
	            select.onchange = null;
	            select.focus();
	        }
	    //CID 0776 //2011.02.06 //Begin
	    } else if (control.isDTText != null && control.isDTText == "true") {
	        //CID 0834 //2011.03.16 //Begin
	        var dtButton = control.dtButton;
	        if (!dtButton) {
	            var box = InfoJet_GetParent(control);
	            var td1 = InfoJet_GetParent(box);
	            var td2 = InfoJet_GetNextElement(td1);
	            dtButton = InfoJet_GetFirstChild(td2);
	        }
	        //CID 0834 //2011.03.16 //End
	        if (dtButton != null) {
	            control.setAttribute("needsFocus", "true");
	            event.keyCode = 0;
	            dtButton.focus();
	            dtButton.onclick();
	        }
	    }
	    //CID 0776 //2011.02.06 //End
	}
	if( event.keyCode == 13 || event.keyCode == 27 ){
		if( control.className != null && control.className.indexOf( "xdComboBox" ) == 0 ){
			var oldClip = control.getAttribute( "oldClip" );
			//While Alt + Down/Up Arrow are pressed, oldClip maybe is null.
			if( oldClip != null ){
				control.style.clip = oldClip;
				control.style.top = "";
				control.size = 1;
				var onchangeFunc = control.getAttribute( "onchangeFunc" );
				if( onchangeFunc != null )
				{
					control.onchange = onchangeFunc;
				}
				InfoJet_OnControlChange( null, control );
				//CID 0255 //2009.05.19 //InfoJet_GetPreviousElement( control )
				var textField = InfoJet_GetPreviousElement( control );
				textField.focus();
			}
		}
	}
	//CID 0249 //2009.03.15 //End
	InfoJet_ResizeTextArea( control, true );
	if( InfoJet_OnKeyDown_xField( event , control ) ){
		return;
	}
	if( InfoJet_OnKeyDown_xTextList( event , control ) ){
		return;
	}
}

//CID 0048 //2008.07.17 //Begin
function InfoJet_OnKeyUp( event , control ){
	event = InfoJet_GetEvent( event );
	if( InfoJet_EnableReplaceGroupingSymbol ){
		InfoJet_ReplaceGroupingSymbol( event, control );
	}
}
//CID 0048 //2008.07.17 //End

//CID 0048 //2008.07.15 //Begin
function InfoJet_ReplaceGroupingSymbol( event, control ){
	//If a "."or "," is entered it will always be decimal separator
    //CID 0500 //2010.07.29 //Begin
    var schemaType = InfoJet_GetSchemaType(control);
    //CID 0500 //2010.07.29 //End
	if( schemaType == "double" ){
		//CID 0471 //2009.12.08 //Begin
		var dataFmtType = InfoJet_GetDataFmtType( control );
		if( dataFmtType == null || dataFmtType == "number" || dataFmtType == "percentage" ){
			if( control.value.indexOf( InfoJet_NumberGroupSeparator ) >= 0 ){
				var controlValue = control.value;
				while( controlValue.indexOf( InfoJet_NumberGroupSeparator ) >= 0 ){
					controlValue = controlValue.replace( InfoJet_NumberGroupSeparator, InfoJet_NumberDecimalSeparator );
				}
				control.value = controlValue;
			}
		}else if( dataFmtType == "currency" ){
			if( control.value.indexOf( InfoJet_CurrencyGroupSeparator ) >= 0 ){
				var controlValue = control.value;
				while( controlValue.indexOf( InfoJet_CurrencyGroupSeparator ) >= 0 ){
					controlValue = controlValue.replace( InfoJet_CurrencyGroupSeparator, InfoJet_CurrencyDecimalSeparator );
				}
				control.value = controlValue;
			}
		}
		//CID 0471 //2009.12.08 //End
	}
}
//CID 0048 //2008.07.15 //End

//CID 0526 //2010.03.31 //Begin
function InfoJet_IsProofingControl( viewName, controlId ){
	if( controlId && InfoJet_NonProofingNodeNameArrays && InfoJet_CurrentViewName ){
		var nonProofingNodeNameArray = InfoJet_NonProofingNodeNameArrays[ InfoJet_CurrentViewName ];
		for( var i = 0; i < nonProofingNodeNameArray.length; i ++ ){
			var noProofingNodeName = nonProofingNodeNameArray[i];
			//CID 0519 //2010.03.26 //Begin
			var lastIndex = controlId.lastIndexOf( noProofingNodeName );
			if( lastIndex > 0 && lastIndex == ( controlId.length - ( noProofingNodeName.length ) ) ){
				return false;
			}
			//CID 0519 //2010.03.26 //End
		}
	}
	return true;
}
//CID 0526 //2010.03.24 //End

//CID 0048 //2008.07.15 //Begin
function InfoJet_GetDataFmtType( element ){
	var datafmt = element.getAttribute( InfoJet_XdPrefix + "datafmt" );
	if( datafmt == null || datafmt.length <= 0 ){
		return null;
	}
	var typeParam = datafmt.split( "\",\"" );
	if( typeParam.length >= 2 ){
		var type = typeParam[ 0 ];
		type = type.substr( 1, type.length - 1 );
		return type;
	}
	return null;
}
//CID 0048 //2008.07.15 //End

//CID 0048 //2008.07.15 //Begin
function InfoJet_GetDataFmtFacetValue( element, targetFaceName ){
	var datafmt = element.getAttribute( InfoJet_XdPrefix + "datafmt" );
	if( datafmt == null || datafmt.length <= 0 ){
		return null;
	}
	var typeParam = datafmt.split( "\",\"" );
	if( typeParam.length >= 2 ){
		var type = typeParam[ 0 ];
		var param = typeParam[ 1 ];
		type = type.substr( 1, type.length - 1 );
		param = param.substr( 0, param.length - 2 );
		
		var params = param.split( ";" );
		for( var i = 0; i < params.length; i ++ ){
			var facet = params[ i ];
			if( facet.length > 0 ){
				var facetNameValue = facet.split( ":" );
				if( facetNameValue.length >= 2 ){
					var facetName = facetNameValue[ 0 ];
					var facetValue = facetNameValue[ 1 ];
					if( facetName == targetFaceName ){
						return facetValue;
					}
				 }
			}
		}
	}
	return null;
}
//CID 0048 //2008.07.15 //End

function InfoJet_OnKeyDown_xField( event , control ){
	var tagName = control.tagName.toLowerCase();
	if( event.keyCode == 13 ){
		if( InfoJet_IsIdInArray( InfoJet_GetElementId( control ) , "xdoc_data_nobreak_id_array" ) ){
		    if (tagName == "textarea") {
		        event.returnValue = false;
				return true;
			}
		}
	}
	return false;
}

//CID 0287 //2009.05.12 //Begin
function InfoJet_IsMultipleLineTextArea( textArea ){
	if( textArea.tagName == null ){
		return false;
	}
	var tagName = textArea.tagName.toLowerCase();
	if( tagName != "textarea" ){
		return false;
	}
	if( textArea.getAttribute( "hasScrollBar" ) == "true" ){
		return false;
	}
	
	var defaultRows = textArea.getAttribute( "default_rows" );
	//CID 0080 //2008.08.04 //Begin
	if( defaultRows != null && defaultRows == "1" ){
		return false;
	}
	//CID 0080 //2008.08.04 //End
	
	return true;
}
//CID 0287 //2009.05.12 //End

function InfoJet_ResizeTextArea( textArea, isRefreshBorder ) 
{
	//CID 0287 //2009.05.12 //Begin
	if( !InfoJet_IsMultipleLineTextArea( textArea ) ){
		return;
	}
	//CID 0287 //2009.05.12 //End
	
	var text = textArea.value; 
	var length = text.length; 
	var rows = 1; 

	var last = 0;
	for( var i = 0; i < length ; i++ ){ 
		if( text.charAt(i).charCodeAt(0) == 13 ){ 
			if( i - last > textArea.cols ){
				rows = rows + ( (i - last) / textArea.cols ) + 1;
			}else{
				rows = rows + 1;
			}
			last = i;
		}
	} 

	if( text.indexOf( "\n" ) < 0 ){
		rows = length / textArea.cols + 1;
	}
	
	//CID 0097 //2008.08.21 //Begin
	//if( defaultRows != null && defaultRows == "3" && rows < 3 ){
	//	rows = 3;
	//}
	//CID 0097 //2008.08.21 //End

	var oldRows = textArea.rows;
	//CID 0097 //2008.08.21 //if
	if( textArea.style.cssText.indexOf( "OVERFLOW-Y: scroll;OVERFLOW-X: scroll;" ) < 0 ){
		textArea.rows = rows; 
	}
	if( isRefreshBorder && oldRows != rows ){
		//CID 0287 //2009.05.11 //!InfoJet_BrowserQuick
		if( !InfoJet_BrowserQuick ){
			InfoJet_HideBorder( "xdoc_field_over" );
			InfoJet_HideBorder( "xdoc_item_over" );
			InfoJet_ShowFieldBorder( textArea , "xdoc_field_focus" );
			if( InfoJet_ItemElement != null ){
				//CID 0403 //2009.09.22 //Begin
				try{
					InfoJet_ShowFocusMenuArrow( InfoJet_ItemElement );
					InfoJet_ShowSectionBorder( InfoJet_ItemElement , "xdoc_item_focus" );
				}catch(e){}
				//CID 0403 //2009.09.22 //End
			}
			//CID 0283 //2009.05.06 //Begin
			//CID 0113 //2008.09.09 //Begin
			InfoJet_RelayoutFieldStyles();
			//CID 0113 //2008.09.09 //End
			//CID 0283 //2009.05.06 //End
		}
	}
}

function InfoJet_OnKeyDown_xTextList( event , control ){
	var key = event.keyCode;
	if( key == 13 || key == 8 ){
		//CID 0332 //2009.08.10 //Begin
		if( InfoJet_IsTextControl( control ) ){
			if( key == 8 ){
				if( control.value.length > 0 ){
					return false;
				}
			}
		}
		//CID 0332 //2009.08.10 //End
		var listIds = document.getElementById( "xdoc_data_list_id_array" ).innerHTML.split( ";" );
		for( index = 0 ; index < listIds.length ; index ++ ){
			var xId = listIds[ index ];
			var id = InfoJet_GetElementId( control );
			if( xId.indexOf( id ) == 0 ){
				//CID 0332 //2009.08.10 //Begin
				InfoJet_OldValueState.valid = true;
				//CID 0332 //2009.08.10 //End
				InfoJet_UpdateField( control );
				InfoJet_RefreshContext( control );
				var xmlToEditName = xId.substr( id.length + 1 );
				document.getElementById( "xdoc_param_xml_to_edit_name" ).value = xmlToEditName;
				if( key == 13 ){
					document.getElementById( "xdoc_param_xml_to_edit_action" ).value = "xTextList::newItem";
				}else if( key == 8 ){
					document.getElementById( "xdoc_param_xml_to_edit_action" ).value = "xTextList::deleteItem";
				}
				//CID 0293 //2009.06.01 //Begin
				InfoJet_MoveProgress2ControlPosition( control );
				//CID 0293 //2009.06.01 //End
				document.getElementById( "xdoc_param_command" ).value = "Update_XmlToEdit";
				//CID 0365 //2009.07.14 //Begin
				control.setAttribute( "postbacked", "true" );
				//CID 0365 //2009.07.14 //End
				InfoJet_Submit();
				//CID 0306 //2009.06.20 //Begin
				InfoJet_CancelEvent( event );
				//CID 0306 //2009.06.20 //End
				event.returnValue = false;
				return true;
			}
		}
	}
	return false;
}

function InfoJet_RemoveFile(source) {
    //CID 1423 //2012.11.01 //Begin
    if (InfoJet_EnablePlaceholderUI) {
        var pureId = InfoJet_GetPureId(source.id);
        var file = InfoJet_GetWriteOnlyField("xdoc" + source.id);
        file.value = "";
        InfoJet_PostbackOnControl(source);
    } else {
        //CID 0047 //2008.07.24 //Begin
        source.innerHTML = "&nbsp;" + InfoJet_SelectFileMessage + "&nbsp";
        //CID 0047 //2008.07.24 //End
        source.href = "javascript:void(0)";
        //CID 0664 //2010.11.18 //Begin
        var file = InfoJet_GetWriteOnlyField("xdoc" + source.id);
        file.value = "";
        //CID 0664 //2010.11.18 //End
        //CID 0496 //2010.02.05 //Begin
        InfoJet_UpdateXDocumentDOM(file);
        //CID 0496 //2010.02.05 //End
        //CID 0861 //2011.04.12 //Begin
        var fileAttachmentSpan = InfoJet_GetParent(source);
        var psvi = InfoJet_GetPSVI(fileAttachmentSpan);
        if (psvi != null && psvi.type == "base64Binary" && psvi.nillable == "false") {
            InfoJet_AddSchemaError(source.id);
            InfoJet_ShowSchemaError(source.id);
        }
        window.setTimeout("InfoJet_RelayoutFieldStyles();", 100);
        //CID 0861 //2011.04.13 //End
    }
    //CID 1423 //2012.11.01 //End
}

function InfoJet_AttachFile(fileAttachment) {
    InfoJet_HideBorder("xdoc_field_focus");
    //CID 0002 //2008.06.04 //Begin
    //CID 1449 //2012.11.10 //Begin
    var fileAttachmentElement = null;
    if (InfoJet_EnablePlaceholderUI) {
        fileAttachmentElement = fileAttachment;
    } else { 
        fileAttachmentElement = InfoJet_GetParent( fileAttachment );
    }
    if (fileAttachmentElement != null) {
        var disableEditing = fileAttachmentElement.getAttribute(InfoJet_XdPrefix + "disableEditing");
		if( disableEditing != null && disableEditing.toLowerCase() == "yes" ){
			return;
		}
    }
    //CID 1449 //2012.11.10 //End
	//CID 0002 //2008.06.04 //End
	if( InfoJet_IsFuncDefined( "InfoJetCustom_AttachFile" ) ){
		//CID 0033 //2008.06.28 //Begin
		var formId = document.getElementById( "xdoc_param_form_id" ).value;
		eval( "InfoJetCustom_AttachFile( fileAttachment, formId );" );
		//CID 0033 //2008.06.28 //End
		return;
	}
	//CID 0033 //2008.06.28 //Begin
	var formId = document.getElementById( "xdoc_param_form_id" ).value;
	//CID 0030 //2008.07.14 //Begin
	//CID 0495 //2010.02.05 //Begin
	//CID 1450 //2012.11.10 //Begin
	var allowedFileTypes = fileAttachmentElement.getAttribute( "allowedFileTypes" );
	//CID 1450 //2012.11.10 //End
    var uploadedFile = window.showModalDialog( InfoJet_WebContext + "js/uploadfile_dialog.htm", new Array( window, fileAttachment, formId, allowedFileTypes ), 'dialogWidth:470px;dialogHeight:125px;help:no;' );
	//CID 0495 //2010.02.05 //End
	if (uploadedFile != null) {
	    //CID 1423 //2012.11.01 //Begin
	    if (InfoJet_EnablePlaceholderUI) {
	        var pureId = InfoJet_GetPureId(fileAttachment.id);
	        var file = InfoJet_GetWriteOnlyField("xdoc" + pureId);
	        file.value = uploadedFile.content;
	        InfoJet_PostbackOnControl(fileAttachment);
	    } else {
	        InfoJet_LinkUploadedFile(fileAttachment, uploadedFile);
	        //CID 0861 //2011.04.12 //Begin
	        var psvi = InfoJet_GetPSVI(fileAttachmentSpan);
	        if (psvi != null && psvi.type == "base64Binary" && psvi.nillable == "false") {
	            InfoJet_RemoveError(fileAttachment.id, 'schema');
	            InfoJet_HideError(fileAttachment.id);
	        }
	        window.setTimeout("InfoJet_RelayoutFieldStyles();", 100);
	        //CID 0861 //2011.04.13 //End
        }
        //CID 1423 //2012.11.01 //End
	}
	//CID 0030 //2008.07.14 //End
	//CID 0033 //2008.06.28 //End
}

//CID 0030 //2008.07.14 //Begin
function InfoJet_LinkUploadedFile( fileAttachment, uploadedFile ){
	var pureId = InfoJet_GetPureId( fileAttachment.id );
	if( fileAttachment.href == null )
	{
		fileAttachment = document.getElementById( pureId + ',1' );
	}
	var linkPath = uploadedFile.path;
	fileAttachment.href = linkPath;
	var name = uploadedFile.name;
	var size = uploadedFile.size;
	//CID 0045 //2008.07.14 //Begin
	fileAttachment.innerHTML = "&nbsp;" + name + '&nbsp;' + size + "&nbsp;";
	//CID 0045 //2008.07.14 //End
	//CID 0664 //2010.11.01 //Begin
	var file = InfoJet_GetWriteOnlyField("xdoc" + pureId);
	file.value = uploadedFile.content;
    //CID 0664 //2010.11.18 //End
	//CID 0496 //2010.02.05 //Begin
	InfoJet_UpdateXDocumentDOM( file );
	//CID 0496 //2010.02.05 //End
}
//CID 0030 //2008.07.14 //End

//CID 0638 //2010.08.08 //Begin
function InfoJet_OnHyperlinkBoxClick(hyperlinkBox) {
    if (hyperlinkBox.tagName && hyperlinkBox.tagName.toLowerCase() == "button") {
        hyperlinkBox = hyperlinkBox.parentNode;
    }
    //0754 //2011.01.18 //Begin
    var button = InfoJet_GetFirstChild(hyperlinkBox);
    if (button.disabled) {
        return false;
    }
    //0754 //2011.01.18 //End
    var style = "help:no;dialogWidth:350px;";
    var bsid = hyperlinkBox.getAttribute("binding_secondary_id");
    if (bsid != null && bsid.length > 0) {
        style = style + "dialogHeight:125px;";
    } else {
        style = style + "dialogHeight:90px;";
    }
    window.showModalDialog(InfoJet_WebContext + "js/editlink_dialog.htm", new Array(window, hyperlinkBox), style);
	return false;
}
//CID 0638 //2010.08.08 //End

//CID 0638 //2010.08.08 //Begin
function InfoJet_AddHyperlinkBoxOnClick(target) {
    //Timeout for FireFox.
    window.setTimeout(function() { target.onclick = function() { return InfoJet_OnHyperlinkBoxClick(this); }; }, 0);
}
//CID 0638 //2010.08.08 //End

//CID 1101 //2012.05.23 //Begin
function InfoJet_OnRichTextBoxFocus(event, source) {
    //CID 1401 //2012.10.19 //Begin
    InfoJet_FocusControlId = source.id;
    if (InfoJet_Postbacking > 0) {
        return;
    }
    //CID 1401 //2012.10.19 //End
    //CID 1201 //2012.05.26 //Begin
    var disableEditing = source.getAttribute(InfoJet_XdPrefix + "disableEditing");
    if (disableEditing != null && disableEditing.toLowerCase() == "yes") {
        //CID 1369 //2012.10.08 //Begin
        source.contentEditable = false;
        //CID 1369 //2012.10.08 //End
        return;
    }
    //CID 1201 //2012.05.26 //End
    //CID 1209 //2012.05.27 //Begin
    var readonly = source.getAttribute("readonly");
    if (readonly != null && readonly.toLowerCase() == "true") {
        //CID 1369 //2012.10.08 //Begin
        source.contentEditable = false;
        //CID 1369 //2012.10.08 //End
        return;
    }
    //CID 1366 //2012.10.04 //Begin
    if(!InfoJet_EditRichTextOnFocus){
        //CID 1209 //2012.05.27 //End
        var pos = InfoJet_GetPos(source);
        if (pos == null) {
            return;
        }
        //1336 //2012.09.17 //Begin
        var isEditing = source.getAttribute("IsEditing");
        if (isEditing != "true") {
            var rtbEditMenu = document.getElementById("xdoc_menu_rtb_edit");
            rtbEditMenu.setAttribute("rtb_id", source.id);
            rtbEditMenu.style.left = pos.left - 18 + 2;
            rtbEditMenu.style.top = pos.top + 2;
            rtbEditMenu.style.display = "block";
        }
        //1336 //2012.09.17 //End
    }else{
        //CID 1366 //2012.10.04 //Begin
        var pureId = InfoJet_GetPureId(source.id);
        //CID 1318 //2012.09.12 //Begin
        InfoJet_InstanceNicEdit(source, pureId);
        //CID 1318 //2012.09.12 //End  
        //CID 1366 //2012.10.04 //Begin
    }
    //CID 1366 //2012.10.04 //End
}
//CID 1101 //2012.05.23 //End

//CID 1366 //2012.10.04 //Begin
//CID 1101 //2012.05.24 //Begin
function InfoJet_OnRichTextBoxEditClick(event, source) {
    var rtbEditMenu = document.getElementById("xdoc_menu_rtb_edit");
    rtbEditMenu.style.display = "none";
    var rtbId = rtbEditMenu.getAttribute("rtb_id");
    rtbEditMenu.removeAttribute(rtbId);
    if (rtbId) {
        var rtb = document.getElementById(rtbId);
        var pureId = InfoJet_GetPureId(rtbId);
        //CID 1318 //2012.09.12 //Begin
        InfoJet_InstanceNicEdit(rtb, pureId);
        //CID 1318 //2012.09.12 //End
    }
}
//CID 1101 //2012.05.24 //End
//CID 1366 //2012.10.04 //End

//CID 1101 //2012.05.24 //Begin
function InfoJet_BuildRTBEditClickHandler() {
    var onRTBEditClick = null;
    if (InfoJet_IsIE()) {
        onRTBEditClick = function () { InfoJet_OnRichTextBoxEditClick(null, this); };
    } else {
        onRTBEditClick = function (event) { return InfoJet_OnRichTextBoxEditClick(event, this); };
    }
    return onRTBEditClick;
}
//CID 1101 //2012.05.24 //End

//CID 1318 //2012.09.12 //Begin
function InfoJet_InstanceNicEdit(editDiv, fieldId) {
    //CID 1376 //2012.10.09 //Begin
    if (InfoJet_NicEditor_PaneExisting) {
        InfoJet_NicEditor_PaneExisting = false;
        return;
    }
    //CID 1376 //2012.10.09 //End
    //CID 1338 //2012.09.18 //Begin
    if (InfoJet_OldValueState) {
        var rteXhtml = new NicEditXHTML();
        var xhtml = rteXhtml.saveXhtml(editDiv);
        InfoJet_OldValueState.textValue = xhtml;
    }
    //CID 1338 //2012.09.18 //End
    //CID 1400 //2012.10.19 //Begin
    var isEditing = editDiv.getAttribute("isEditing");
    if (isEditing == "true") {
        return;
    }
    //CID 1400 //2012.10.19 //End
    //CID 1336 //2012.09.17 //Begin
    editDiv.setAttribute("isEditing", "true");
    InfoJet_NicEditor = new nicEditor({ iconsPath: InfoJet_WebContext + "images/nicEditorIcons.gif" });
    InfoJet_NicEditor.setPanel(InfoJet_RtbPanel);
    InfoJet_NicEditor.addInstance(editDiv);
    //CID 1336 //2012.09.17 //End
    var pos = InfoJet_GetPos(editDiv);
    InfoJet_RtbPanel.style.height = 22*1;
    //CID 1367 //2012.10.06 //Begin
    //CID 1393 //2012.10.12 //Begin
    InfoJet_RtbPanel.style.width = 396; //22*18
    //CID 1393 //2012.10.12 //End
    //CID 1367 //2012.10.06 //End
    InfoJet_RtbPanel.style.left = pos.left;
    InfoJet_RtbPanel.style.top = pos.top - 22*1;
    InfoJet_RtbPanel.style.display = "block";
}
//CID 1318 //2012.09.12 //End

//CID 1321 //2012.09.13 //Begin
function InfoJet_OnNicEditBlur(editDiv) {
    //CID 1376 //2012.10.09 //Begin
    if (InfoJet_NicEditor_PaneExisting) {
        return;
    }
    //CID 1376 //2012.10.09 //End
    //CID 1323 //2012.09.14 //Begin
    var rteXhtml = new NicEditXHTML();
    var xhtml = rteXhtml.saveXhtml(editDiv);
    //CID 1323 //2012.09.14 //End
    //CID 1324 //2012.09.14 //Begin
    var fieldId = InfoJet_GetPureId(editDiv.id);
    //CID 1239 //2012.09.15 //Begin
    InfoJet_RtbPanel.style.display = "none";
    //CID 1239 //2012.09.15 //End
    //CID 1324 //2012.09.14 //End
    //CID 1336 //2012.09.17 //Begin
    InfoJet_NicEditor.removeInstance(editDiv);
    InfoJet_NicEditor = null;
    editDiv.removeAttribute("isEditing");
    //CID 1336 //2012.09.17 //End
    //CID 1369 //2012.10.07 //Begin
    editDiv.contentEditable = true;
    //CID 1369 //2012.10.07 //End
    //CID 0664 //2010.11.18 //Begin
    var xmlField = document.getElementById("xdoc" + fieldId);
    if (xmlField.value != xhtml) {
        xmlField.value = xhtml;
        document.getElementById("xdoc_param_old_value").value = xhtml;
        //CID 1380 //2012.10.07 //Begin
        InfoJet_MoveProgress2ControlPosition(editDiv);
        //CID 1380 //2012.10.07 //End
        InfoJet_CheckPostback(editDiv, false, false);
    }
    //CID 0664 //2010.11.18 //End
}
//CID 1321 //2012.09.13 //End

//Event Hanlder Build
function InfoJet_BuildMouseOutHandler(){
	var onMouseOut = null;
	if( InfoJet_IsIE() ){
		onMouseOut = function(){ InfoJet_OnMouseOut(null,this); };
	}else{
		onMouseOut = function(event){ InfoJet_OnMouseOut(event,this); };
	}
	return onMouseOut;
}

function InfoJet_BuildDocMouseOutHandler(){
	var onMouseOut = null;
	if( InfoJet_IsIE() ){
		onMouseOut = function(){ InfoJet_OnMouseOut(window.event,window.event.srcElement); };
	}else{
		onMouseOut = function(event){ InfoJet_OnMouseOut(event,event.target); };
	}
	return onMouseOut;
}


function InfoJet_BuildMouseOverHandler(type){
	var onMouseOver = null;
	if( InfoJet_IsIE() ){
		onMouseOver = function(){ InfoJet_OnMouseOver(null,this,type); };
	}else{
		onMouseOver = function(event){ InfoJet_OnMouseOver(event,this,type); };
	}
	return onMouseOver;
}

function InfoJet_BuildDocMouseOverHandler(type){
	var onMouseOver = null;
	if( InfoJet_IsIE() ){
		onMouseOver = function(){ InfoJet_OnMouseOver(window.event,window.event.srcElement,type); };
	}else{
		onMouseOver = function(event){ InfoJet_OnMouseOver(event,event.target,type); };
	}
	return onMouseOver;
}

function InfoJet_BuildBlurHandler(type){
	var onBlur = null;
	if( InfoJet_IsIE() ){
		onBlur = function(){ InfoJet_OnBlur(null,this,type); };
	}else{
		onBlur = function(event){ InfoJet_OnBlur(event,this,type); };
	}
	return onBlur;
}

function InfoJet_BuildDocBlurHandler(type){
	var onBlur = null;
	if( InfoJet_IsIE() ){
		onBlur = function(){ InfoJet_OnBlur(window.event,window.event.srcElement,type); };
	}else{
		onBlur = function(event){ InfoJet_OnBlur(event,event.target,type); };
	}
	return onBlur;
}

function InfoJet_BuildFocusHandler(type){
	var onFocus = null;
	if( InfoJet_IsIE() ){
		onFocus = function(){ InfoJet_OnFocus(null,this,type); };
	}else{
		onFocus = function(event){ InfoJet_OnFocus(event,this,type); };
	}
	return onFocus;
}

function InfoJet_BuildDocFocusHandler(type){
	var onFocus = null;
	if( InfoJet_IsIE() ){
		onFocus = function(){ InfoJet_OnFocus(window.event,window.event.srcElement,type); };
	}else{
		onFocus = function(event){ InfoJet_OnFocus(event,event.target,type); };
	}
	return onFocus;
}

function InfoJet_BuildDocClickHandler(type){
	var onClick = null;
	if( InfoJet_IsIE() ){
		//CID 0132 //2008.10.04 //Begin
		onClick = function(){ if( event.srcElement.onclick == null ){ InfoJet_OnClick(window.event,window.event.srcElement,type); } };
		//CID 0132 //2008.10.04 //End
	}else{
		//CID 0132 //2008.10.04 //Begin
		onClick = function(event){ if( event.target.onclick == null ){ InfoJet_OnClick(event,event.target,type); } };
		//CID 0132 //2008.10.04 //End
	}
	return onClick;
}

function InfoJet_BuildContextMenuHandler(){
	var onContextMenu = null;
	if( InfoJet_IsIE() ){
		onContextMenu = function(){ InfoJet_OnContextMenu(null,this); };
	}else{
		onContextMenu = function(event){ return InfoJet_OnContextMenu(event,this); };
	}
	return onContextMenu;
}

function InfoJet_BuildDocContextMenuHandler(){
	var onContextMenu = null;
	if( InfoJet_IsIE() ){
		onContextMenu = function(){ InfoJet_OnContextMenu(window.event,window.event.srcElement); };
	}else{
		onContextMenu = function(event){ return InfoJet_OnContextMenu(event,event.target); };
	}
	return onContextMenu;
}

function InfoJet_BuildMenuArrowPointHandler( type ){
	var onMenuArrowPoint = null;
	if( InfoJet_IsIE() ){
		onMenuArrowPoint = function(){ InfoJet_OnMenuArrowPoint(null,this,type); };
	}else{
		onMenuArrowPoint = function(event){ return InfoJet_OnMenuArrowPoint(event,this,type); };
	}
	return onMenuArrowPoint;
}

function InfoJet_FormatTextArea(){
	var taIdArray = document.getElementById( "xdoc_data_textarea_id_array" ).innerHTML;
	var taIds = taIdArray.split( ";" );
	for( var i = 0 ; i < taIds.length ; i ++ ){
		var taId = taIds[ i ];
		if( taId.length > 0 ){
			var textArea = document.getElementById( taId );
			if( textArea != null ){
				InfoJet_ResizeTextArea( textArea, false );
			}
		}
	}
}

//CID 0834 //2011.03.16 //Begin
//CID 1171 //2012.04.24 //imprecise
function InfoJet_OnDatePickerClick(event, button, imprecise) {
    //CID 1171 //2012.04.24 //Begin
    var input = null;
    if (imprecise) {
        input = InfoJet_GetPreviousElement(button);
    } else {
        var td2 = InfoJet_GetParent(button);
        var td1 = InfoJet_GetPreviousElement(td2);
        var box = InfoJet_GetFirstChild(td1);
        input = InfoJet_GetFirstChild(box);
    }
    //CID 1171 //2012.04.24 //End
    //CID 0946 //2011.06.09 //Begin
    var dateNum = input.getAttribute("date_num");
    if (dateNum == null) {
        dateNum = input.getAttribute(InfoJet_XdPrefix + "num");
    }
    var tIndex = dateNum.indexOf("T");
    if (tIndex > 0) {
        dateNum = dateNum.substring(0, tIndex);
    }
    if (dateNum == null) {
        dateNum = "";
    }
    input.setAttribute("date_num", dateNum);
    //CID 0953 //2011.06.23 //End
    if (!input.dtButton) {
        var dateFormat = InfoJet_GetDateFormat(input);
        input.dtButton = button;
        Calendar.setup({
            xdocInputField: input,
            ifFormat: dateFormat,
            showsTime: false,
            xdocButton: button,
            singleClick: true,
            step: 1,
            onClose: InfoJet_OnCalendarClose
        });
    }
    button.clickPickerButton();
    //CID 0877 //2011.04.21 //Begin
    InfoJet_StopEvent(event);
    return false;
    //CID 0877 //2011.04.21 //End
}
//CID 0834 //2011.03.16 //End

//CID 0776 //2011.02.06 //Begin
function InfoJet_OnCalendarClose(calendar) {
    calendar.hide();
    var inputField = calendar.params.xdocInputField;
    var needsFocus = inputField.getAttribute("needsFocus");
    if( needsFocus != null && needsFocus == "true"){
        inputField.removeAttribute("needsFocus");
        inputField.focus();
    }
}
//CID 0776 //2011.02.06 //End

//CID 0050 //2008.07.18 //Begin
function InfoJet_AlignDTPickerButton(parentElement, input, button) {
    //CID 0439 //2009.10.22 //Begin
	input.style.textAlign = parentElement.style.textAlign;
	//CID 0439 //2009.10.22 //End
	if( InfoJet_IsIE() ){
		input.style.top = parentElement.clientTop;
		//CID 0274 //2009.04.23 //-2
		if( parentElement.clientWidth - button.offsetWidth - 2 > 0 ){
			input.style.width = parentElement.clientWidth - button.offsetWidth - 2;
		}
		//CID 0425 //2009.10.16 //Begin
		if( input.offsetLeft > 0 ){
			input.style.marginLeft = - input.offsetLeft;
		}
		//CID 0425 //2009.10.16 //End
		if( parentElement.clientHeight - 2 > 0 ){
			input.style.height = parentElement.clientHeight - 2;
			//CID 0121 //2008.09.26 //Begin
			input.style.lineHeight = input.style.height;
			//CID 0121 //2008.09.26 //End
		}
	}else{
		//CID 0057 //2008.07.19 //Begin
		var parentWidth = InfoJet_GetStylePixelSize( parentElement , "width" , "width" );;
		input.style.width = parentWidth - button.offsetWidth - 2;
		parentElement.style.paddingTop = "2px";
		parentElement.style.paddingBottom = "2px";
		//CID 0057 //2008.07.19 //End
	}
}
//CID 0050 //2008.07.18 //End

//CID 1171 //2012.04.24 //Begin
function InfoJet_FormatDTPicker() {
    var dtpIdArrayElement = document.getElementById("xdoc_data_datepicker_id_array");
    if(dtpIdArrayElement != null){
        var dtpIdArray = dtpIdArrayElement.innerHTML;
        var dtpIds = dtpIdArray.split(";");
        for (var i = 0; i < dtpIds.length; i++) {
            var dtpId = dtpIds[i]
            if (dtpId.length > 0) {
                var datePickerInput = document.getElementById(dtpId);
                if (datePickerInput != null) {
                    var parentElement = InfoJet_GetParent(datePickerInput);
                    var datePickerButton = InfoJet_GetNextElement(datePickerInput);
                    InfoJet_AlignDTPickerButton(parentElement, datePickerInput, datePickerButton);
                }
            }
        }
    }

}
//CID 1171 //2012.04.24 //End

//CID 0288 //2009.05.21 //Begin
function InfoJet_FormatComboBox(){
	var comboBoxPlaceholder = document.getElementById( "ComboBoxPlaceholder" );
	var index = 1;
	while( comboBoxPlaceholder != null ){
		var input = InfoJet_GetNextElement( comboBoxPlaceholder );
		var select = InfoJet_GetNextElement( input );
		var width = comboBoxPlaceholder.offsetWidth;
		input.style.width = width;
		input.style.marginLeft = "-" + width;
		select.style.width = width;
		select.style.marginLeft = "-" + width;
		select.style.clip = "rect(auto auto auto " + (width - 18) + ")";
		input.style.height = select.offsetHeight;
		comboBoxPlaceholder = document.getElementById( "ComboBoxPlaceholder," + index );
		index ++;
	}	
}
//CID 0288 //2009.05.21 //End

function InfoJet_BuildMenuArrowPoint(){
	var readonlyView = false;
	var xdocArrow = document.getElementById( "xdoc_arrow" );
	if( xdocArrow.innerHTML == "ReadonlyView" ){
		readonlyView = true;
	}
	
	var content = "<div id='xdoc_menu_focus_arrow' style='display: none;Z-INDEX: 98;POSITION: absolute;'>";
	content += "<img id='xdoc_menu_focus_arrow_img' src='" + InfoJet_WebContext + "images/infojet_transparent.gif'></img></div>";
	
	//CID 0010 //2008.06.05 //Begin
	//content += "<div id='xdoc_menu_over_arrow' style='display: none;Z-INDEX: 97;POSITION: absolute;'>";
	//content += "<img id='xdoc_menu_over_arrow_img' src='" + InfoJet_WebContext + "images/infojet_transparent.gif'></img></div>";
	//CID 0010 //2008.06.05 //End

	//CID 1366 //2012.10.04 //Begin
	if (!InfoJet_EditRichTextOnFocus) {
	    //CID 1102 //2012.05.23 //Begin
	    content += "<div id='xdoc_menu_rtb_edit' style='display: none;Z-INDEX: 97;POSITION: absolute;'>";
	    content += "<img id='xdoc_menu_rtb_edit_img' src='" + InfoJet_WebContext + "Images/infojet_menu_rtb_edit.gif'></img></div>";
	    //CID 1102 //2012.05.23 //End
	}
    //CID 1366 //2012.10.04 //End

	//CID 1320 //2012.09.12 //Begin
	content += "<div id='xdoc_menu_rtb_panel' style='display: none;Z-INDEX: 97;POSITION: absolute;'></div>";
	//CID 1320 //2012.09.12 //End
	
	xdocArrow.innerHTML = content;
	
	var menuArrow = document.getElementById( "xdoc_menu_focus_arrow" );
	menuArrow.onblur = function(){ InfoJet_OnBlur("menu"); };
	menuArrow.onclick = InfoJet_BuildMenuArrowPointHandler("arrow");
	menuArrow.oncontextmenu = InfoJet_BuildMenuArrowPointHandler("arrow");

	//CID 1366 //2012.10.04 //Begin
	if (!InfoJet_EditRichTextOnFocus) {
	    //CID 1102 //2012.05.23 //Begin
	    var rtbEdit = document.getElementById("xdoc_menu_rtb_edit");
	    rtbEdit.onblur = function () { InfoJet_OnBlur("menu"); };
	    rtbEdit.onclick = InfoJet_BuildRTBEditClickHandler();
	    rtbEdit.oncontextmenu = function () { return; };
	    //CID 1102 //2012.05.23 //End
	}
    //CID 1366 //2012.10.04 //End

	//CID 1320 //2012.09.12 //Begin
	InfoJet_RtbPanel = document.getElementById("xdoc_menu_rtb_panel");
	//CID 1320 //2012.09.12 //End
	
	//如果是ReadonlyView.
	if( readonlyView ){
		menuArrow.onclick = "javascript:void(0)";
		menuArrow.oncontextmenu = "javascript:void(0)";
	}
}

function InfoJet_Init(){
	var xdoc = document.getElementById( "xdoc" );
	if( !xdoc ){
		return;
	}
	//设置InfoJet_XdPrefix
	InfoJet_XdPrefix = document.getElementById( "xdoc_data_xd_prefix" ).innerHTML;
	
	//CID 0492 //2010.02.05 //Begin
	if( typeof(InfoJetCustom_InitContainer) != "undefined" ){
		InfoJetCustom_InitContainer( xdoc );
	}
	if( InfoJet_Container == null ){
		InfoJet_Container = document.body;
	}
	if (typeof (InfoJetCustom_ResetOffset) != "undefined") {
        InfoJetCustom_ResetOffset();
    }
	//CID 0492 //2010.02.05 //End
	
	var menu = document.getElementById( "xdoc_data_menu" );
	var menuHtml = menu.getAttribute( "html" );
	if( menuHtml.length > 0 ){
		var xdocMenu = document.getElementById( "xdoc_menu" );
		if( xdocMenu != null ){
			//CID 0020 //2008.06.20 //Begin
			InfoJet_RemoveHtmlElement( xdocMenu ); //unreachable code //CID 0020 //2008.06.20 //comment
			//CID 0020 //2008.06.20 //End
		}
		//CID 0017 //2008.06.16 //Begin
		InfoJet_InsertAdjacentHTMLBeforeEnd( document.body, menuHtml );
		//CID 0017 //2008.06.16 //End
	}
	var style = document.getElementById( "xdoc_fieldstyle" );
	if( style != null ){
		style.innerHTML = "";
	}else{
		//CID 0017 //2008.06.16 //Begin
		InfoJet_InsertAdjacentHTMLBeforeEnd( InfoJet_Container, "<div id='xdoc_fieldstyle' style='width:0px;height:0px;'></div>" );
		//CID 0017 //2008.06.16 //End
	}
	var focus = document.getElementById( "xdoc_focusover" );
	if( focus == null ){
		//CID 0017 //2008.06.16 //Begin
		InfoJet_InsertAdjacentHTMLBeforeEnd( InfoJet_Container, "<div id='xdoc_focusover' style='width:0px;height:0px;'></div>" );
		//CID 0017 //2008.06.16 //End
		//CID 0300 //2009.06.04 //Begin
		InfoJet_BuildFocusOverBorder();
		//CID 0300 //2009.06.04 //End
	}
	var arrow = document.getElementById( "xdoc_arrow" );
	if( arrow == null ){
		//CID 0017 //2008.06.16 //Begin
		InfoJet_InsertAdjacentHTMLBeforeEnd( InfoJet_Container, "<div id='xdoc_arrow' style='width:0px;height:0px;'></div>" );
		//CID 0017 //2008.06.16 //End
		//CID 0300 //2009.06.04 //Begin
		InfoJet_BuildMenuArrowPoint();
		//CID 0300 //2009.06.04 //End
	}
	
	InfoJet_BuildProgress();
	
	//CID 0407 //2009.09.27 //Begin
	if( InfoJet_HookDocumentOnClickEvent ){
		document.onclick = InfoJet_BuildDocClickHandler('common');
	}else{
		xdoc.onclick = InfoJet_BuildDocClickHandler('common');
	}
	xdoc.oncontextmenu = InfoJet_BuildDocContextMenuHandler('common');
	xdoc.onblur = InfoJet_BuildDocBlurHandler('common');
	//CID 0407 //2009.09.27 //End
	
	if( !InfoJet_BrowserQuick ){
		//CID 0407 //2009.09.27 //Begin
		xdoc.onmouseover = InfoJet_BuildDocMouseOverHandler('common');
		xdoc.onmouseout = InfoJet_BuildDocMouseOutHandler();
		//CID 0407 //2009.09.27 //End
	}

	//CID 0834 //2011.03.16 //Begin
	InfoJet_ShortDatePattern = document.getElementById("xdoc_data_short_date_pattern").innerHTML;
	InfoJet_LongDatePattern = document.getElementById("xdoc_data_long_date_pattern").innerHTML;
	InfoJet_YearMonthPattern = document.getElementById("xdoc_data_year_month_pattern").innerHTML;
	//CID 0834 //2011.03.16 //End

	//CID 1171 //2012.04.24 //Begin
	InfoJet_FormatDTPicker();
	//CID 1171 //2012.04.24 //End
	InfoJet_FormatTextArea();
	//CID 0288 //2009.05.21 //Begin
	InfoJet_FormatComboBox();
	//CID 0288 //2009.05.21 //End
	if( !InfoJet_NoValidation ){
		InfoJet_ShowAllErrors();
	}
	InfoJet_HiddenAllGroupMenu();
	//CID 0284 //2009.05.10 //Begin
	//InfoJet_ResetSwitchViewMenuCheck();
	//CID 0284 //2009.05.10 //End
	InfoJet_HideOverBorderArrow();
	InfoJet_HideFocusBorderArrow();
	window.onresize = InfoJet_OnWindowResize;
	
	if( InfoJet_FuncAfterInit != null ){
		eval( InfoJet_FuncAfterInit );
		InfoJet_FuncAfterInit = null;
	}
	
	//CID 0286 //2009.05.11 //Begin
	InfoJet_XmlToEditItems = null;
	//CID 0286 //2009.05.11 //End

	InfoJet_Inited();

	//CID 0880 //2011.04.22 //Begin
	if (InfoJet_PingParameter != null) {
	    if (!InfoJet_IsPinging) {
	        window.setTimeout("InfoJet_Ping();", InfoJet_PingInterval);
	        InfoJet_IsPinging = true;
	    }
	}
	//CID 0880 //2011.04.22 //End
	
	//CID 0400 //2009.11.24 //Begin
	if( InfoJet_FocusFirstControlAfterInited ){
		InfoJet_FocusFirstControlAfterInited = false;
		InfoJet_FocusFirstControlAutomatically();
	}
	//CID 0400 //2009.11.24 //End
	
	InfoJet_BuildXDocumentDOM();
}

function InfoJet_Inited(){
	var xdoc = document.getElementById( "xdoc" );
	xdoc.setAttribute( "inited" , "true" );
}

function InfoJet_IsInited(){
	var xdoc = document.getElementById( "xdoc" );
	//CID 0487 //2010.01.14 //Begin
	if( xdoc == null ){
		return false;
	}
	//CID 0487 //2010.01.14 //End
	var inited = xdoc.getAttribute( "inited" );
	if( inited != null && inited == "true" ){
		return true;
	}else{
		return false;
	}
}

function InfoJet_ReloadForm(){
	var frameDocument = InfoJet_GetFrameDocument( "xdoc_frame" );
	var frameView = frameDocument.getElementById('xdoc_view');
	var frameForm = frameDocument.getElementById('xdoc_form');
	var frameData = frameDocument.getElementById('xdoc_data');
	if( frameView.value.length > 0 ){
		document.getElementById('xdoc_view').innerHTML = frameView.value;
	}
	document.getElementById('xdoc_form').innerHTML = frameForm.value;
	document.getElementById('xdoc_data').innerHTML = frameData.value;
	InfoJet_Init();
	InfoJet_Changed = true;
}

function InfoJet_ReloadFormVars( viewHtml, formHtml, dataHtml ){
	if( viewHtml.length > 0 ){
		document.getElementById('xdoc_view').innerHTML = viewHtml;
	}
	document.getElementById('xdoc_form').innerHTML = formHtml;
	document.getElementById('xdoc_data').innerHTML = dataHtml;
	InfoJet_Init();
	InfoJet_Changed = true;
}

function InfoJet_OnWindowResize(){
	//CID 0113 //2008.09.09 //Begin
	InfoJet_RelayoutFieldStyles();
	//CID 0113 //2008.09.09 //End
	//CID 1227 //2012.07.16 //Begin
	if (InfoJet_FocusControlId) { 
	    var focusControl = document.getElementById(InfoJet_FocusControlId);
	    if (focusControl && InfoJet_NeedFieldBorder(focusControl)) {
	        InfoJet_ShowFieldBorder(focusControl, "xdoc_field_focus");
	    }
	}
	//CID 1227 //2012.07.16 //End
	if( typeof(Custom_InfoJetWebFormHost_OnWindowResize) != "undefined" ){
		eval( "Custom_InfoJetWebFormHost_OnWindowResize();" );
	}
}

//CID 0113 //2008.09.09 //Begin
function InfoJet_RelayoutFieldStyles(){
	var xdocFieldStyles = document.getElementById( "xdoc_fieldstyle" );
	if( xdocFieldStyles == null ){
		return;
	}
	var invalidateFieldIds = new Array();
	var notBlankFieldIds = new Array();
	for( var i = 0; i < xdocFieldStyles.childNodes.length; i ++ ){
		var fieldStyle = xdocFieldStyles.childNodes[ i ];
		if( fieldStyle.nodeType == 1 ){
			var fieldId = fieldStyle.id;
			if( fieldId.lastIndexOf( "_top" ) == (fieldId.length - 4) ){
				if( parseInt(fieldStyle.style.height) > 0 || parseInt(fieldStyle.style.width) > 0 ){
					invalidateFieldIds[ invalidateFieldIds.length ] = fieldId.substr( 0, fieldId.length - 4 );
				}
			}
			if( fieldId.lastIndexOf( "_notBlank" ) == (fieldId.length - 9) ){
				if( fieldStyle.style.display != "none" ){
					notBlankFieldIds[ notBlankFieldIds.length ] = fieldId.substr( 0, fieldId.length - 9 );
				}
			}
		}
	}
	for( var index = 0; index < invalidateFieldIds.length; index ++ ){
		var field = document.getElementById( invalidateFieldIds[ index ] );
		if( field != null ){
			InfoJet_ShowInvalidateBorder( field );
		}
	}
	for( var index = 0; index < notBlankFieldIds.length; index ++ ){
		var field = document.getElementById( notBlankFieldIds[ index ] );
		if( field != null ){
			InfoJet_ShowNotBlankMark( field );
		}
	}
}
//CID 0113 //2008.09.09 //End

function InfoJet_SetViewReadonly(){
	var allViewElements = InfoJet_GetAllChildren( document.getElementById( "xdoc_view" ) );
	for( var i = 0; i < allViewElements.length; i++ ) {
	    var element = allViewElements[i];
	    var tagName = element.tagName.toLowerCase();
		if (tagName == "input") {
			var type = element.getAttribute( "type" );
			if( type != null ){
				type = type.toLowerCase();
				if( type == "text" || type == "password" ){
					    element.readOnly = true;
					    element.contentEditable = false;
	                } else {
	                //CID 0754 //2011.01.05 //if
	                if (type != "button") {
	                    element.disabled = true;
	                }
				}
			}else{
				element.disabled = true;
			}
        } else if (tagName == "textarea") {
			element.readOnly = true;
			element.contentEditable = false;
        } else if (tagName == "select") {
            //CID 0785 //2011.02.22 //Begin
            if (InfoJet_FormatReadonlyView) {
                var text = "";
                if (element.selectedIndex >= 0) {
                    text = element.options[element.selectedIndex].text.replace(/\'/g, "\\'");
                }
                var inputHtml = "<input type='text' class='xdTextBox' style='" + element.style.cssText + "' readOnly='true' value='" + text + "'/>";
                InfoJet_ReplaceNodeWithHTML(element, inputHtml);
            } else {
                element.disabled = true;
            }
            //CID 0785 //2011.02.22 //End	
        } else if (tagName == "button") {
            //CID 0754 //2011.01.18 //Begin
            if ( element.className != "xdPictureButton" ) {
                element.disabled = true;
            }
            //CID 0754 //2011.01.18 //End
		    //CID 0670 //2010.09.29 //Begin
            if (InfoJet_FormatReadonlyView) {
		        if ( element.className && element.className == "xdDTButton" ) {
		            InfoJet_RemoveHtmlElement(element);
		        }
		    }
		    //CID 0785 //2011.02.22 //End
		}else if( element.className && element.className == "xdInlinePicture" ){
			element.disabled = true;
		}else if( element.className && element.className == "xdLinkedPicture" ){
			element.disabled = true;
		}else if( element.className && element.className == "xdFileAttachmentLink" ){
			var href = element.href;
			if( href.indexOf( "javascript:void(0)" ) == 0 ){
				element.onclick = null;
			}else{
				element.setAttribute( "fileHref", href );
				element.href = "javascript:void(0)";
				//CID 0029 //2009.10.13 //Begin
				element.onclick = function(){ window.open( this.getAttribute( "fileHref" ) ); };
				//CID 0029 //2009.10.13 //End
			}
		}else if( element.className && element.className == "optionalPlaceholder" ){
			//CID 0096 //2009.10.08 //Begin
			if( InfoJet_IsIE() ){
				element.disabled = true;
			}else{
				element.setAttribute( "disabled", "true" );
			}
			//CID 0096 //2009.10.08 //End
		}
    }
    //CID 0400 //2009.11.23 //Begin
    InfoJet_RemoveFocus();
    //CID 0400 //2009.11.23 //End
}

//CID 0296 //2009.06.23 //Begin
function InfoJet_GetFirstElementInNewStructureNode(){
	if( InfoJet_NewStructureNodeId != null ){
		var structureElement = document.getElementById( InfoJet_NewStructureNodeId );
		if( structureElement != null ){
			var firstControl = InfoJet_FindFocusableControlInElement( structureElement );
			//CID 0366 //2009.07.13 //if
			if( firstControl != null ){
				InfoJet_FocusControlId = firstControl.id;
			}
		}
	}
}
//CID 0296 //2009.06.23 //End

//CID 0255 //2009.03.22 //Begin
function InfoJet_RestoreFocus(){
	//CID 0296 //2009.06.23 //Begin
	InfoJet_GetFirstElementInNewStructureNode();
	//CID 0296 //2009.06.23 //End
	if( InfoJet_FocusControlId != null ){
		try
		{
			var field = document.getElementById( InfoJet_FocusControlId );
			if( field != null ){
				//CID 0311 //2009.06.16 //Begin
				if( !InfoJet_IsReadyForFocus( field ) ){
					var nextField = InfoJet_FindNextFocusableControl( field );
					if( nextField != null ){
						field = nextField;
					}
				}
				//CID 0311 //2009.06.16 //End
				//CID 0828 //2011.03.10 //Begin
				var isItemsContainer = field.getAttribute("isItemsContainer");
				if (isItemsContainer != null && isItemsContainer == "true") {
				    InfoJet_RestoreFocusOnItemsContainer(field);
				} else {
				    field.focus();
				}
				//CID 0828 //2011.03.10 //End
				//CID 0255 //2009.05.20 //Begin
				if( field.tagName.toLowerCase() == "input" ){
					var type = field.getAttribute( "type" );
					if( type != null && type == "text" ){
						field.select();
					}
				}
				//CID 0255 //2009.05.20 //End
			}
		}catch( e ){}
	}
	InfoJet_FocusControlId = null;
}
//CID 0255 //2009.03.22 //End

//CID 0828 //2011.03.10 //Begin
function InfoJet_RestoreFocusOnItemsContainer(container) {
    var found = false;
    if (InfoJet_FocusItemIndex != -1) {
        InfoJet_FocusItemIndex = InfoJet_FocusItemIndex * 2;
        var elements = InfoJet_GetElements(container);
        if (elements.length > 0) {
            if (InfoJet_FocusItemIndex < elements.length) {
                elements[InfoJet_FocusItemIndex].focus();
                found = true;
            } else {
                elements[elements.length - 2].focus();
                found = true;
            }
        }
    }
    if (!found) {
        var td = InfoJet_GetParent(container);
        var td2 = InfoJet_GetNextElement(td);
        var button = InfoJet_GetFirstChild(td2);
        button.focus();
    }
    InfoJet_FocusItemIndex = -1;
}
//CID 0828 //2011.03.10 //End

//CID 0369 //2009.07.19 //Begin
function InfoJet_OpenNewForm( publishUrl, isCurrentTemplate ){
	if( typeof(InfoJetCustom_OpenNewForm) != "undefined" ){
		InfoJetCustom_OpenNewForm( publishUrl, isCurrentTemplate );
	}else{
		alert( "InfoJetCustom_OpenNewForm() is not defined." );
	}
}
//CID 0369 //2009.07.19 //End

//Called in InfoJet_Init().
function InfoJet_BuildXDocumentDOM(){
	var dataXml = document.getElementById( "xdoc_data_xml" );
	if( dataXml != null ){
		var xml = dataXml.getAttribute( "xml" );
		InfoJet_XDocumentDOM = new ActiveXObject('Msxml2.DOMDocument.3.0');
		if( InfoJet_XDocumentDOM == null ){
			return;
		}
		InfoJet_XDocumentDOM.loadXML(xml);
	}else{
		InfoJet_XDocumentDOM = null;
	}
}

//Called in the value change postback response.
function InfoJet_LoadXDocumentDOM( xml ){
	var dataXml = document.getElementById( "xdoc_data_xml" );
	if( dataXml != null )
	{
		dataXml.innerHTML = xml;
		var innerXml = dataXml.innerHTML;
		dataXml.innerHTML = "";
		if( InfoJet_XDocumentDOM != null ){
			InfoJet_XDocumentDOM.loadXML(innerXml);
		}
	}
}

function InfoJet_UpdateXDocumentDOM( xmlField ){
	//CID 0230 //2009.02.25 //xmlField.indexOf( "xdoc_s_" ) < 0
	//CID 0488 //2010.01.14 //xmlField.id.indexOf
	if( InfoJet_XDocumentDOM != null && xmlField.id.indexOf( "xdoc_s_" ) < 0 ){
		var ids = xmlField.id.split( "@" );
		var elementId = ids[0].replace( "xdoc", "" );
		var element = InfoJet_XDocumentDOM.selectSingleNode( "//*[@JetId='" + elementId + "']" );
		if( element != null ){
			if( ids.length == 1 ){
				element.text = xmlField.value;
			}else{
				element.setAttribute( ids[1], xmlField.value );
			}
		}
	}
}

function InfoJet_UpdateFormFieldByDOMNode( node ){
	var jetId = null;
	var value = null;
	if( node.nodeType == 1 ){
		jetId = node.getAttribute( "JetId" );
		value = node.text;
	}else if( node.nodeType == 2 ){
		var element = node.selectSingleNode( ".." );
		jetId = element.getAttribute( "JetId" );
		jetId = jetId + "@" + node.nodeName;
		value = node.value;
	}
	var xmlField = document.getElementById( "xdoc" + jetId );
	xmlField.value = value;
	var firstHtmlField = null;
	for( var n = 0 ; true ; n ++ ){
		var htmlId = jetId;
		if( n != 0 ){
			htmlId = htmlId + "," + n;
		}
		var htmlField = document.getElementById( htmlId );
		if( htmlField == null ){
			break;
		}else{
			if( n == 0 ){
				firstHtmlField = htmlField;
			}
			var tagName = htmlField.tagName.toLowerCase();
			if( tagName == "select" ){
				htmlField.value = value;
			}else if( tagName == "img" ){
				htmlField.src = value;
			}else if( tagName == "input" ){
				var type = htmlField.type.toLowerCase();
				if( type == "text" || type == "password" ){
					htmlField.setAttribute( "xml_value", value );
					htmlField.value = value;
				}else if( type == "checkbox" ){
					var onValue = InfoJet_GetOnOffValue( htmlField, true );
					var offValue = InfoJet_GetOnOffValue( htmlField, false );
					if( onValue == value ){
						htmlField.checked = true;
					}
					if( offValue == value ){
						htmlField.checked = false;
					}
				}else if( type == "radio" ){
					var onValue = InfoJet_GetOnOffValue( htmlField, true );
					if( onValue == value ){
						htmlField.checked = true;
					}else{
						htmlField.checked = false;
					}
				}
			}else if( tagName == "textarea" ){
				//CID 0092 //2008.08.14 //Begin
				htmlField.setAttribute( "xml_value", value );
				//CID 0092 //2008.08.14 //End
				htmlField.value = value;
			}
		}
		if( firstHtmlField != null ){
			InfoJet_OnControlChange( null, firstHtmlField );
		}
	}
}

//-------------------------------------------------
function InfoJet_GetDateFormat( element ){
	var datafmt = element.getAttribute( InfoJet_XdPrefix + "datafmt" );
	if( datafmt == null || datafmt.length <= 0 ){
		return "%Y-%m-%d";
	}
	var typeParam = datafmt.split( "\",\"" );
	if( typeParam.length >= 2 ){
		var type = typeParam[ 0 ];
		var param = typeParam[ 1 ];
		type = type.substr( 1, type.length - 1 );
		param = param.substr( 0, param.length - 2 );
		
		var params = param.split( ";" );
		for( var i = 0; i < params.length; i ++ ){
			var facet = params[ i ];
			if( facet.length > 0 ){
				var facetNameValue = facet.split( ":" );
				if( facetNameValue.length >= 2 ){
					var facetName = facetNameValue[ 0 ];
					var facetValue = facetNameValue[ 1 ];
					if( facetName == "dateFormat" ){
						dateFormat = facetValue;
						if( dateFormat.length <= 0 ){
							return "%Y-%m-%d";
						}
						if( dateFormat == "Long Date" ){
							dateFormat = InfoJet_LongDatePattern;
						}
						if( dateFormat == "Year Month" ){
							dateFormat = InfoJet_YearMonthPattern;
						}
						if( dateFormat == "Short Date" ){
							dateFormat = InfoJet_ShortDatePattern;
						}
						if( dateFormat.indexOf( "dddd" ) >= 0 ){
							return "%Y-%m-%d";
						}
						if( dateFormat.indexOf( "MMMM" ) >= 0 ){
							return "%Y-%m-%d";
						}
						if( dateFormat.indexOf( "MMM" ) >= 0 ){
							return "%Y-%m-%d";
						}
						dateFormat = dateFormat.replace( /\'/g, "" );
						if( dateFormat.indexOf( "yyyy" ) >= 0 ){
							dateFormat = dateFormat.replace( "yyyy", "%Y" );
						}else if( dateFormat.indexOf( "yy" ) >= 0 ){
							dateFormat = dateFormat.replace( "yy", "%Y" );
						}
						if( dateFormat.indexOf( "MM" ) >= 0 ){
							dateFormat = dateFormat.replace( "MM", "%m" );
						}else if( dateFormat.indexOf( "M" ) >= 0 ){
							dateFormat = dateFormat.replace( "M", "%m" );
						}
						if( dateFormat.indexOf( "dd" ) >= 0 ){
							dateFormat = dateFormat.replace( "dd", "%d" );
						}else if( dateFormat.indexOf( "d" ) >= 0 ){
							dateFormat = dateFormat.replace( "d", "%d" );
						}
						return dateFormat;
					}
				 }
			}
		}
	}
	return "%Y-%m-%d";
}
function InfoJet_DataFmt( element ){
	var datafmt = element.getAttribute( InfoJet_XdPrefix + "datafmt" );
	if( datafmt == null || datafmt.length <= 0 ){
		return 0;
	}
	var typeParam = datafmt.split( "\",\"" );
	if( typeParam.length >= 2 ){
		var type = typeParam[ 0 ];
		var param = typeParam[ 1 ];
		type = type.substr( 1, type.length - 1 );
		param = param.substr( 0, param.length - 2 );
		
		var numDigits = "", grouping = "", negativeOrder = "", positiveOrder = "", currencyLocale = "", locale = "", dateFormat = "", timeFormat = "";
		var params = param.split( ";" );
		for( var i = 0; i < params.length; i ++ ){
			var facet = params[ i ];
			if( facet.length > 0 ){
				var facetNameValue = facet.split( ":" );
				if( facetNameValue.length >= 2 ){
					var facetName = facetNameValue[ 0 ];
					var facetValue = facetNameValue[ 1 ];
					if( facetName == "numDigits" ){
						numDigits = facetValue;
					}else if( facetName == "grouping" ){
						grouping = facetValue;
					}else if( facetName == "negativeOrder" ){
						negativeOrder = facetValue;
					}else if( facetName == "positiveOrder" ){
						positiveOrder = facetValue;
					}else if( facetName == "currencyLocale" ){
						currencyLocale = facetValue;
					}else if( facetName == "locale" ){
						locale = facetValue;
					}else if( facetName == "dateFormat" ){
						dateFormat = facetValue;
					}else if( facetName == "timeFormat" ){
						timeFormat = facetValue;
					}
				 }
			}
        }
	
		return InfoJet_DoFormat( element, type, numDigits, grouping, negativeOrder, positiveOrder, currencyLocale, locale, dateFormat, timeFormat );
	}
	return 0;
}

//CID 0102 //2008.08.26 //Begin
var InfoJet_LocaleIdArray = new Array( "1052", "1068", "2092", "1061", "1069", "1076", "1026", "3131", "1083", "2107", "1132", "1059", "1039", "1045", "5146", "1042", "1074", "1092", "1030", "3079", "1031", "5127", "4103", "2055", "1049", "1080", "2060", "1036", "3084", "5132", "3076", "6156", "4108", "1035", "1087", "2067", "1043", "1088", "1110", "1027", "1029", "1050", "4122", "1131", "2155", "3179", "1062", "1063", "4155", "5179", "1048", "1082", "1086", "2110", "1071", "1153", "1104", "1078", "6203", "7227", "1044", "4100", "2068", "1046", "2070", "1041", "1053", "2077", "2074", "3098", "6170", "7194", "8251", "1051", "1060", "1089", "1055", "1106", "1058", "1091", "2115", "11274", "15370", "6154", "20490", "16394", "1034", "7178", "12298", "9226", "5130", "3082", "2052", "18442", "10250", "2058", "19466", "17418", "4106", "8202", "14346", "13322", "1032", "1038", "9275", "2064", "1040", "1057", "6153", "3081", "10249", "13321", "9225", "4105", "12297", "1033", "7177", "11273", "5129", "8201", "2057", "5124", "1028", "1077", "15361", "3073", "13313", "14337", "1054" );
var InfoJet_CurrencySymbolArray = new Array( "Lek", "man.", "ман.", "kr", "€", "$", "лв", "$", "$", "$", "$", "р.", "kr.", "zł", "$", "₩", "$", "р.", "kr", "€", "€", "CHF", "€", "SFr.", "р.", "kr", "€", "€", "$", "€", "HK$", "€", "SFr.", "€", "Т", "€", "€", "сом", "€", "€", "Kč", "kn", "$", "$", "$", "$", "Ls", "Lt", "$", "$", "lei", "$", "R", "$", "ден.", "$", "₮", "R", "$", "$", "kr", "$", "kr", "R$ ", "€", "¥", "kr", "€", "Din.", "Дин.", "$", "$", "$", "Sk", "SIT", "S", "TL", "$", "грн.", "su'm", "сўм", "$", "Gs", "B/.", "$", "$b", "€", "RD$", "$", "$", "₡", "€", "￥", "L.", "S/.", "$", "C$", "$", "Q", "Bs", "$U", "$", "€", "Ft", "$", "SFr.", "€", "Rp", "€", "$", "BZ$", "Php", "$", "$", "Z$", "$", "R", "TT$", "$", "J$", "£", "P", "NT$", "$", "د.ب.", "ج.م.", "د.ك.", "د.إ.", "฿" );
//CID 0102 //2008.08.26 //End

function InfoJet_GetCurrencySybmol( localeId ){
	for( var i = 0; i < InfoJet_LocaleIdArray.length; i ++ ){
		if( InfoJet_LocaleIdArray[ i ] == localeId ){
			return InfoJet_CurrencySymbolArray[ i ];
		}
	}
	return "$";
}

function InfoJet_GetCurDecimalSeparator( localeId ){
	for( var i = 0; i < InfoJet_LocaleIdArray.length; i ++ ){
		if( InfoJet_LocaleIdArray[ i ] == localeId ){
			if( InfoJet_CurSeparatorTypeArray[ i ] == "1" ){
				return ".";
			}else{
				return ",";
			}
		}
	}
	return ".";
}

function InfoJet_GetCurSeparatorType( localeId ){
	for( var i = 0; i < InfoJet_LocaleIdArray.length; i ++ ){
		if( InfoJet_LocaleIdArray[ i ] == localeId ){
			return InfoJet_CurSeparatorTypeArray[ i ];
		}
	}
	return "1";
}

//CID 0344 //2009.06.30 //Begin
//CID 0772 //2011.02.22 //Begin
var InfoJet_DateFormats = new Array("MM-dd-yyyy", "MM-dd-yy", "M-d-yyyy", "M-d-yy", "dd-MM-yyyy", "dd-MM-yy", "d-M-yyyy", "d-M-yy", "yyyy-MM-dd", "yyyy-M-d", "yy-MM-dd", "yy-M-d", "dd MMMM yyyy");
//CID 0772 //2011.02.22 //End
//CID 0344 //2009.06.30 //End

//CID 0344 //2009.06.30 //Begin
function InfoJet_ParseDate( dateString ){
	var date = null;
	for( var i = 0; i < InfoJet_DateFormats.length; i ++ ){
		var format = InfoJet_DateFormats[ i ];
		date = Date.parseString( dateString, format );
		if( date != null ){
			return date;
		}
	}
	return null;
}
//CID 0344 //2009.06.30 //End

function InfoJet_DoFormat(element, type, numDigits, grouping, negativeOrder, positiveOrder, currencyLocale, locale, dateFormat, timeFormat) {
    //CID 0940 //2011.06.02 //Begin
    var value = InfoJet_GetControlValue(element);
	//CID 0940 //2011.06.02 //End
	//CID 0116 //2008.09.15 //Begin
	//CID 0500 //2010.07.29 //Begin
	var schemaType = InfoJet_GetSchemaType(element);
	//CID 0500 //2010.07.29 //End
	//CID 0116 //2008.09.15 //End
	
	//CID 0500 //2010.07.29 //Begin
	if (schemaType == "string") {
	    return 1;
	}
	//CID 0500 //2010.07.29 //End
	
	if( value.length <= 0 ){
		if( type == "boolean" || type == "string" || type == "anyURI" || type == "any" ){
			//Don't need xml_value.
			return 1;
		}
		if( type == "number" || type == "currency" || type == "percentage" ){
			element.setAttribute( "xml_value", "" );
			return 1;
		}
		//date/time type is handlered in the following codes.
	}
	
	if( type == "number" ){
		var formatedValue = "";
		var numberValue = ""
		//CID 0520 //2010.03.29 //154
		var num = new NumberFormat154();
		
		//CID 0471 //2009.11.30 //Begin
		if( InfoJet_NumberDecimalSeparator != "." && InfoJet_NumberGroupSeparator != "." ){
			value = value.replace(/\./g, InfoJet_NumberDecimalSeparator);
		}
		num.setInputDecimal( InfoJet_NumberDecimalSeparator );
		//CID 0471 //2009.11.30 //End
		
		num.setNumber(value);
		num.setCurrencyValue('$');
		num.setCurrency(false);
		num.setCurrencyPosition(num.LEFT_OUTSIDE);
		num.setNegativeRed(false);
		if( numDigits == "auto" ){
			num.setPlaces('-1', false);
		}else{
			if( numDigits == '0' ){
				num.setPlaces(numDigits, true);
			}else{
				num.setPlaces(numDigits, false);
			}
		}
		if( grouping == "0" ){
			num.setSeparators(false, ',', ',');
		}else{
			//CID 0471 //2009.11.30 //Begin
			num.setSeparators(true, InfoJet_NumberGroupSeparator, InfoJet_NumberDecimalSeparator);
			//CID 0471 //2009.11.30 //End
		}
		if( negativeOrder == "0" ){
			num.setNegativeFormat(num.PARENTHESIS);
		}else if( negativeOrder == "1" ){
			num.setNegativeFormat(num.LEFT_DASH);
		}else if( negativeOrder == "2" ){
			num.setNegativeFormat(num.LEFT_DASHSPACE);	
		}else if( negativeOrder == "3" ){
			num.setNegativeFormat(num.RIGHT_DASH);
		}else if( negativeOrder == "4" ){
			num.setNegativeFormat(num.RIGHT_DASHSPACE);
		}
		formatedValue = num.toFormatted();
		//CID 0401 //2009.09.15 //Begin
		//CID 0915 //2011.05.17 //if InfoJet_IsValidNumberChars
		if (num.isValid && InfoJet_IsValidNumberChars(value)) {
			//CID 0116 //2008.09.15 //Begin
			if( schemaType != null && schemaType.indexOf( "int" ) >= 0 ){
				numberValue = num.getOriginalInteger();
			}else{
				numberValue = num.getOriginal();
			}
			//CID 0116 //2008.09.15 //End
			element.value = formatedValue;
			element.setAttribute( "xml_value", numberValue );
			return 1;
		}else{
			element.setAttribute( "xml_value", value );
			return -1;
		}
		//CID 0401 //2009.09.15 //End
	}else if( type == "currency" ){
		var formatedValue = "";
		var numberValue = ""
		//CID 0520 //2010.03.29 //154
		var num = new NumberFormat154();
		
		//CID 0471 //2009.12.06 //Begin
		if( InfoJet_CurrencyDecimalSeparator != "." && InfoJet_CurrencyGroupSeparator != "." ){
			value = value.replace(/\./g, InfoJet_CurrencyDecimalSeparator);
		}
		num.setInputDecimal( InfoJet_CurrencyDecimalSeparator );
		//CID 0471 //2009.12.06 //End
		
		num.setNumber(value);
		num.setNegativeRed(false);
		if( numDigits == "auto" ){
			num.setPlaces('-1', false);
		}else{
			if( numDigits == '0' ){
				num.setPlaces(numDigits, true);
			}else{
				num.setPlaces(numDigits, false);
			}
		}
		if( grouping == "0" ){
			num.setSeparators(false, ',', ',');
		}else{
			//CID 0471 //2009.11.30 //Begin
			num.setSeparators(true, InfoJet_CurrencyGroupSeparator, InfoJet_CurrencyDecimalSeparator);
			//CID 0471 //2009.11.30 //End
		}
		var currencySymbol = InfoJet_GetCurrencySybmol( currencyLocale );
		if( negativeOrder == "0" && positiveOrder == "0" ){
			num.setNegativeFormat(num.PARENTHESIS);
			num.setCurrencyPosition(num.LEFT_INSIDE);
		}else if( negativeOrder == "1" && positiveOrder == "0" ){
			num.setNegativeFormat(num.LEFT_DASH);
			num.setCurrencyPosition(num.LEFT_INSIDE);
		}else if( negativeOrder == "2" && positiveOrder == "0" ){
			num.setNegativeFormat(num.LEFT_DASH);
			num.setCurrencyPosition(num.LEFT_OUTSIDE);
		}else if( negativeOrder == "3" && positiveOrder == "0" ){
			num.setNegativeFormat(num.RIGHT_DASH);
			num.setCurrencyPosition(num.LEFT_INSIDE);
		}else if( negativeOrder == "4" && positiveOrder == "1" ){
			num.setNegativeFormat(num.PARENTHESIS);
			num.setCurrencyPosition(num.RIGHT_INSIDE);
		}else if( negativeOrder == "5" && positiveOrder == "1" ){
			num.setNegativeFormat(num.LEFT_DASH);
			num.setCurrencyPosition(num.RIGHT_INSIDE);
		}else if( negativeOrder == "6" && positiveOrder == "1" ){
			num.setNegativeFormat(num.RIGHT_DASH);
			num.setCurrencyPosition(num.RIGHT_OUTSIDE);
		}else if( negativeOrder == "7" && positiveOrder == "1" ){
			num.setNegativeFormat(num.RIGHT_DASH);
			num.setCurrencyPosition(num.RIGHT_INSIDE);
		}else if( negativeOrder == "8" && positiveOrder == "3" ){
			currencySymbol = " " + currencySymbol;
			num.setNegativeFormat(num.LEFT_DASH);
			num.setCurrencyPosition(num.RIGHT_INSIDE);
		}else if( negativeOrder == "9" && positiveOrder == "2" ){
			currencySymbol = currencySymbol + " ";
			num.setNegativeFormat(num.LEFT_DASH);
			num.setCurrencyPosition(num.LEFT_INSIDE);
		}else if( negativeOrder == "10" && positiveOrder == "3" ){
			currencySymbol = " " + currencySymbol;
			num.setNegativeFormat(num.RIGHT_DASH);
			num.setCurrencyPosition(num.RIGHT_INSIDE);
		}else if( negativeOrder == "11" && positiveOrder == "2" ){
			currencySymbol = currencySymbol + " ";
			num.setNegativeFormat(num.RIGHT_DASH);
			num.setCurrencyPosition(num.LEFT_INSIDE);
		}else if( negativeOrder == "12" && positiveOrder == "2" ){
			currencySymbol = currencySymbol + " ";
			num.setNegativeFormat(num.LEFT_DASH);
			num.setCurrencyPosition(num.LEFT_OUTSIDE);
		}else if( negativeOrder == "13" && positiveOrder == "3" ){
			currencySymbol = " " + currencySymbol;
			num.setNegativeFormat(num.RIGHT_DASH);
			num.setCurrencyPosition(num.RIGHT_OUTSIDE);
		}else if( negativeOrder == "14" && positiveOrder == "2" ){
			currencySymbol = currencySymbol + " ";
			num.setNegativeFormat(num.PARENTHESIS);
			num.setCurrencyPosition(num.LEFT_INSIDE);
		}else if( negativeOrder == "15" && positiveOrder == "3" ){
			currencySymbol = " " + currencySymbol;
			num.setNegativeFormat(num.PARENTHESIS);
			num.setCurrencyPosition(num.RIGHT_INSIDE);
		}
		num.setCurrencyValue(currencySymbol);
		num.setCurrency(true);
		formatedValue = num.toFormatted();
		//CID 0401 //2009.09.15 //Begin
		if( num.isValid ){
			//CID 0116 //2008.09.15 //Begin
			if( schemaType != null && schemaType.indexOf( "int" ) >= 0 ){
				numberValue = num.getOriginalInteger();
			}else{
				numberValue = num.getOriginal();
			}
			//CID 0116 //2008.09.15 //End
			element.value = formatedValue;
			element.setAttribute( "xml_value", numberValue );
			return 1;
		}else{
			element.setAttribute( "xml_value", value );
			return -1;
		}
		//CID 0401 //2009.09.15 //End
	}else if( type == "percentage" ){
		var formatedValue = "";
		var numberValue = ""
		//CID 0520 //2010.03.29 //154
		var num = new NumberFormat154();
		
		//CID 0471 //2009.11.30 //Begin
		if( InfoJet_NumberDecimalSeparator != "." && InfoJet_NumberGroupSeparator != "." ){
			value = value.replace(/\./g, InfoJet_NumberDecimalSeparator);
		}
		num.setInputDecimal( InfoJet_NumberDecimalSeparator );
		//CID 0471 //2009.11.30 //End
		
		num.setNumber(value);
		num.setCurrencyValue('$');
		num.setCurrency(false);
		num.setCurrencyPosition(num.LEFT_OUTSIDE);
		num.setNegativeRed(false);
		if( numDigits == "auto" ){
			num.setPlaces('-1', false);
		}else{
			num.setPlaces(numDigits, false);
		}
		if( grouping == "0" ){
			num.setSeparators(false, ',', ',');
		}else{
			//CID 0471 //2009.11.30 //Begin
			num.setSeparators(true, InfoJet_NumberGroupSeparator, InfoJet_NumberDecimalSeparator);
			//CID 0471 //2009.11.30 //End
		}
		if( negativeOrder == "0" ){
			num.setNegativeFormat(num.PARENTHESIS);
		}else if( negativeOrder == "1" ){
			num.setNegativeFormat(num.LEFT_DASH);
		}else if( negativeOrder == "2" ){
			num.setNegativeFormat(num.LEFT_DASHSPACE);	
		}else if( negativeOrder == "3" ){
			num.setNegativeFormat(num.RIGHT_DASH);
		}else if( negativeOrder == "4" ){
			num.setNegativeFormat(num.RIGHT_DASHSPACE);
		}
		formatedValue = num.toFormatted();
		//CID 0401 //2009.09.15 //Begin
		if( num.isValid ){
			numberValue = num.getOriginalPercentage();
			element.value = formatedValue;
			element.setAttribute( "xml_value", numberValue );
			return 1;
		}else{
			element.setAttribute( "xml_value", value );
			return -1;
		}
		//CID 0401 //2009.09.15 //End
	}else if( type == "boolean" ){
	    //Don't need xml_value.
	    //CID 1018 //2011.09.28 //Begin
	    if (value == "1" || value == "0") {
	        element.value = value;
	    } else {
	        if (value == "true") {
	            element.value = "true";
	        } else {
	            element.value = "false";
	        }
	    }
	    //CID 1018 //2011.09.28 //End
		return 1;
	}else if( type == "string" ){
		//Don't need xml_value.
		return 1;
	}else if( type == "anyURI" ){
		//Don't need xml_value.
		return 1;
	}else if( type == "any" ){
		//Don't need xml_value.
		return 1;
	}else if( type == "date" ){
		if( dateFormat.length <= 0 ){
			return 0;
		}
		if( dateFormat == "Long Date" ){
			dateFormat = InfoJet_LongDatePattern;
		}
		if( dateFormat == "Year Month" ){
			dateFormat = InfoJet_YearMonthPattern;
		}
		if( dateFormat == "Short Date" ){
			dateFormat = InfoJet_ShortDatePattern;
		}
		if( dateFormat.indexOf( "dddd" ) >= 0 ){
			return 0;
		}
		if( dateFormat.indexOf( "MMMM" ) >= 0 ){
			return 0;
		}
		if( dateFormat.indexOf( "MMM" ) >= 0 ){
			return 0;
		}
		if( dateFormat.indexOf( "'" ) >= 0 ){
			return 0;
		}
		if( dateFormat.indexOf( "yyyy" ) < 0 && dateFormat.indexOf( "yy" ) >=0 ){
			return 0;
		}
		var date = Date.parseString( value, dateFormat );
		if( date == null ){
			//CID 0344 //2009.06.30 //Begin
			date = InfoJet_ParseDate( value );
			if( date == null ){
				if( value.length <= 0 ){
					element.setAttribute( "xml_value", "" );
					return 1;
				}else{
					element.setAttribute( "xml_value", value );
					return -1;
				}
			}
			//CID 0344 //2009.06.30 //End
		}
		element.value = date.format( dateFormat );
		element.setAttribute( "xml_value", date.format( "yyyy-MM-dd" ) );
		return 1;
	}else if( type == "time" ){
		//No need xml_value.
		return 0;
	}else if( type == "datetime" ){
		if( timeFormat == "none" ){
			if( dateFormat.length <= 0 ){
				return 0;
			}
			if( dateFormat == "Long Date" ){
				dateFormat = InfoJet_LongDatePattern;
			}
			if( dateFormat == "Year Month" ){
				dateFormat = InfoJet_YearMonthPattern;
			}
			if( dateFormat == "Short Date" ){
				dateFormat = InfoJet_ShortDatePattern;
			}
			if( dateFormat.indexOf( "dddd" ) >= 0 ){
				return 0;
			}
			if( dateFormat.indexOf( "MMMM" ) >= 0 ){
				return 0;
			}
			if( dateFormat.indexOf( "'" ) >= 0 ){
				return 0;
			}
			var date = Date.parseString( value, dateFormat );
			if( date == null ){
				//CID 0344 //2009.06.30 //Begin
				date = InfoJet_ParseDate( value );
				if( date == null ){
					if( value.length <= 0 ){
						element.setAttribute( "xml_value", "" );
						return 1;
					}else{
						element.setAttribute( "xml_value", value );
						return -1;
					}
				}
				//CID 0344 //2009.06.30 //End
			}
			element.value = date.format(dateFormat);
			//CID 0809 //2011.03.02 //Begin
			var dateValue = date.format( "yyyy-MM-dd" );
			var xmlValue = dateValue + "T00:00:00";
			var xdnum = element.getAttribute(InfoJet_XdPrefix + "num");
			if (xdnum) {
			    var tIndex = xdnum.indexOf("T");
			    if (tIndex > 0) {
			        var timeValue = xdnum.substring(tIndex);
			        xmlValue = dateValue + timeValue;
			    }
			}
			element.setAttribute("xml_value", xmlValue);
			//CID 0809 //2011.03.02 //End
			return 1;
        }
        //CID 0809 //2011.03.02 //Begin
        if (dateFormat == "none") {
            var xdnum = element.getAttribute(InfoJet_XdPrefix + "num");
            if (xdnum) {
                var tIndex = xdnum.indexOf("T");
                if (tIndex > 0) {
                    var dateValue = xdnum.substring(0, tIndex);
                    element.setAttribute("xml_value", dateValue + " " + value);
                    return -1;
                }
            }
        }
        //CID 0809 //2011.03.02 //End
		return 0;
	}else if( type == "unknown" ){
		//No need xml_value.
		return 0;
	}
	//No need xml_value.
	return 0;
}

//CID 0915 //2011.05.17 //Begin
function InfoJet_IsValidNumberChars(numVal) {
    var re = new RegExp('[\\' + InfoJet_NumberGroupSeparator + '\\' + InfoJet_NumberDecimalSeparator + '\\d\\-\\+\\(\\)eE ]', 'g');
    numVal = numVal.replace(re, '');
    if (numVal.length <= 0) {
        return true;
    } else {
        return false;
    }
}
//CID 0915 //2011.05.17 //End

//-------------------------------------------------
// NumberFormat154.js
//-------------------------------------------------
// mredkj.com
//CID 0520 //2010.03.29 //154
function NumberFormat154(num, inputDecimal)
{
this.VERSION = 'Number Format v1.5.4';
this.COMMA = ',';
this.PERIOD = '.';
this.DASH = '-'; 
this.LEFT_PAREN = '('; 
this.RIGHT_PAREN = ')'; 
this.LEFT_OUTSIDE = 0; 
this.LEFT_INSIDE = 1;  
this.RIGHT_INSIDE = 2;  
this.RIGHT_OUTSIDE = 3;  
this.LEFT_DASH = 0; 
this.RIGHT_DASH = 1; 
this.PARENTHESIS = 2; 
this.LEFT_DASHSPACE = 3;
this.RIGHT_DASHSPACE = 4;
this.NO_ROUNDING = -1 
this.num;
this.hasSeparators = false;  
this.separatorValue;  
this.inputDecimalValue; 
this.decimalValue;  
this.negativeFormat; 
this.negativeRed; 
this.hasCurrency;  
this.currencyPosition;  
this.currencyValue;  
this.places;
this.roundToPlaces; 
this.truncate;
//CID 0401 //2009.09.15 //Begin
this.isValid;
//CID 0401 //2009.09.15 //End
this.setNumber = setNumberNF;
this.toUnformatted = toUnformattedNF;
this.setInputDecimal = setInputDecimalNF; 
this.setSeparators = setSeparatorsNF; 
this.setCommas = setCommasNF;
this.setNegativeFormat = setNegativeFormatNF; 
this.setNegativeRed = setNegativeRedNF; 
this.setCurrency = setCurrencyNF;
this.setCurrencyPrefix = setCurrencyPrefixNF;
this.setCurrencyValue = setCurrencyValueNF; 
this.setCurrencyPosition = setCurrencyPositionNF; 
this.setPlaces = setPlacesNF;
this.toFormatted = toFormattedNF;
this.toPercentage = toPercentageNF;
this.getOriginal = getOriginalNF;
this.getOriginalPercentage = getOriginalPercentageNF;
this.getOriginalInteger = getOriginalIntegerNF;
this.moveDecimalRight = moveDecimalRightNF;
this.moveDecimalLeft = moveDecimalLeftNF;
this.getRounded = getRoundedNF;
this.preserveZeros = preserveZerosNF;
this.justNumber = justNumberNF;
this.expandExponential = expandExponentialNF;
this.getZeros = getZerosNF;
this.moveDecimalAsString = moveDecimalAsStringNF;
this.moveDecimal = moveDecimalNF;
this.addSeparators = addSeparatorsNF;
if (inputDecimal == null) {
this.setNumber(num, this.PERIOD);
} else {
this.setNumber(num, inputDecimal); 
}
this.setCommas(true);
this.setNegativeFormat(this.LEFT_DASH); 
this.setNegativeRed(false); 
this.setCurrency(false); 
this.setCurrencyPrefix('$');
this.setPlaces(2);
}
function setInputDecimalNF(val)
{
this.inputDecimalValue = val;
}
function setNumberNF(num, inputDecimal)
{
if (inputDecimal != null) {
this.setInputDecimal(inputDecimal); 
}
this.num = this.justNumber(num);
}
function toUnformattedNF()
{
return (this.num);
}
function getOriginalNF()
{
return (this.num);
}
function getOriginalPercentageNF()
{
return (parseFloat( this.moveDecimalLeft(this.num + '', 2) ));
}
function getOriginalIntegerNF()
{
return (parseInt( this.num ));
}
function setNegativeFormatNF(format)
{
this.negativeFormat = format;
}
function setNegativeRedNF(isRed)
{
this.negativeRed = isRed;
}
function setSeparatorsNF(isC, separator, decimal)
{
this.hasSeparators = isC;
if (separator == null) separator = this.COMMA;
if (decimal == null) decimal = this.PERIOD;
if (separator == decimal) {
this.decimalValue = (decimal == this.PERIOD) ? this.COMMA : this.PERIOD;
} else {
this.decimalValue = decimal;
}
this.separatorValue = separator;
}
function setCommasNF(isC)
{
this.setSeparators(isC, this.COMMA, this.PERIOD);
}
function setCurrencyNF(isC)
{
this.hasCurrency = isC;
}
function setCurrencyValueNF(val)
{
this.currencyValue = val;
}
function setCurrencyPrefixNF(cp)
{
this.setCurrencyValue(cp);
this.setCurrencyPosition(this.LEFT_OUTSIDE);
}
function setCurrencyPositionNF(cp)
{
this.currencyPosition = cp
}
function setPlacesNF(p, tr)
{
this.roundToPlaces = !(p == this.NO_ROUNDING); 
this.truncate = (tr != null && tr); 
this.places = (p < 0) ? 0 : p; 
}
function addSeparatorsNF(nStr, inD, outD, sep)
{
nStr += '';
var dpos = nStr.indexOf(inD);
var nStrEnd = '';
if (dpos != -1) {
nStrEnd = outD + nStr.substring(dpos + 1, nStr.length);
nStr = nStr.substring(0, dpos);
}
//CID 0048 & CID 6907 // IM // 25-7-2008 //if
if (!InfoJet_EnableReplaceGroupingSymbol) {
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(nStr)) {
		nStr = nStr.replace(rgx, '$1' + sep + '$2');
	}
}
return nStr + nStrEnd;
}
function toFormattedNF()
{	
var pos;
var nNum = this.num; 
var nStr;            
var splitString = new Array(2);   
if (this.roundToPlaces) {
nNum = this.getRounded(nNum);
nStr = this.preserveZeros(Math.abs(nNum)); 
} else {
nStr = this.expandExponential(Math.abs(nNum)); 
}
if (this.hasSeparators) {
nStr = this.addSeparators(nStr, this.PERIOD, this.decimalValue, this.separatorValue);
} else {
nStr = nStr.replace(new RegExp('\\' + this.PERIOD), this.decimalValue); 
}
var c0 = '';
var n0 = '';
var c1 = '';
var n1 = '';
var n2 = '';
var c2 = '';
var n3 = '';
var c3 = '';
var negSignL = (this.negativeFormat == this.PARENTHESIS) ? this.LEFT_PAREN : this.DASH;
var negSignR = (this.negativeFormat == this.PARENTHESIS) ? this.RIGHT_PAREN : this.DASH;
if (this.currencyPosition == this.LEFT_OUTSIDE) {
if (nNum < 0) {
if (this.negativeFormat == this.LEFT_DASH || this.negativeFormat == this.PARENTHESIS) n1 = negSignL;
if (this.negativeFormat == this.RIGHT_DASH || this.negativeFormat == this.PARENTHESIS) n2 = negSignR;
if (this.negativeFormat == this.LEFT_DASHSPACE ){ n1 = "- "; }
if (this.negativeFormat == this.RIGHT_DASHSPACE ){ n2 = " -"; }
}
if (this.hasCurrency) c0 = this.currencyValue;
} else if (this.currencyPosition == this.LEFT_INSIDE) {
if (nNum < 0) {
if (this.negativeFormat == this.LEFT_DASH || this.negativeFormat == this.PARENTHESIS) n0 = negSignL;
if (this.negativeFormat == this.RIGHT_DASH || this.negativeFormat == this.PARENTHESIS) n3 = negSignR;
}
if (this.hasCurrency) c1 = this.currencyValue;
}
else if (this.currencyPosition == this.RIGHT_INSIDE) {
if (nNum < 0) {
if (this.negativeFormat == this.LEFT_DASH || this.negativeFormat == this.PARENTHESIS) n0 = negSignL;
if (this.negativeFormat == this.RIGHT_DASH || this.negativeFormat == this.PARENTHESIS) n3 = negSignR;
}
if (this.hasCurrency) c2 = this.currencyValue;
}
else if (this.currencyPosition == this.RIGHT_OUTSIDE) {
if (nNum < 0) {
if (this.negativeFormat == this.LEFT_DASH || this.negativeFormat == this.PARENTHESIS) n1 = negSignL;
if (this.negativeFormat == this.RIGHT_DASH || this.negativeFormat == this.PARENTHESIS) n2 = negSignR;
}
if (this.hasCurrency) c3 = this.currencyValue;
}
nStr = c0 + n0 + c1 + n1 + nStr + n2 + c2 + n3 + c3;
if (this.negativeRed && nNum < 0) {
nStr = '<font color="red">' + nStr + '</font>';
}
return (nStr);
}
function toPercentageNF()
{
nNum = this.num * 100;
nNum = this.getRounded(nNum);
return nNum + '%';
}
function getZerosNF(places)
{
var extraZ = '';
var i;
for (i=0; i<places; i++) {
extraZ += '0';
}
return extraZ;
}
function expandExponentialNF(origVal)
{
if (isNaN(origVal)) return origVal;
var newVal = parseFloat(origVal) + ''; 
var eLoc = newVal.toLowerCase().indexOf('e');
if (eLoc != -1) {
var plusLoc = newVal.toLowerCase().indexOf('+');
var negLoc = newVal.toLowerCase().indexOf('-', eLoc); 
var justNumber = newVal.substring(0, eLoc);
if (negLoc != -1) {
var places = newVal.substring(negLoc + 1, newVal.length);
justNumber = this.moveDecimalAsString(justNumber, true, parseInt(places));
} else {
if (plusLoc == -1) plusLoc = eLoc;
var places = newVal.substring(plusLoc + 1, newVal.length);
justNumber = this.moveDecimalAsString(justNumber, false, parseInt(places));
}
newVal = justNumber;
}
return newVal;
} 
function moveDecimalRightNF(val, places)
{
var newVal = '';
if (places == null) {
newVal = this.moveDecimal(val, false);
} else {
newVal = this.moveDecimal(val, false, places);
}
return newVal;
}
function moveDecimalLeftNF(val, places)
{
var newVal = '';
if (places == null) {
newVal = this.moveDecimal(val, true);
} else {
newVal = this.moveDecimal(val, true, places);
}
return newVal;
}
function moveDecimalAsStringNF(val, left, places)
{
var spaces = (arguments.length < 3) ? this.places : places;
if (spaces <= 0) return val; 
var newVal = val + '';
var extraZ = this.getZeros(spaces);
var re1 = new RegExp('([0-9.]+)');
if (left) {
newVal = newVal.replace(re1, extraZ + '$1');
var re2 = new RegExp('(-?)([0-9]*)([0-9]{' + spaces + '})(\\.?)');		
newVal = newVal.replace(re2, '$1$2.$3');
} else {
var reArray = re1.exec(newVal); 
if (reArray != null) {
newVal = newVal.substring(0,reArray.index) + reArray[1] + extraZ + newVal.substring(reArray.index + reArray[0].length); 
}
var re2 = new RegExp('(-?)([0-9]*)(\\.?)([0-9]{' + spaces + '})');
newVal = newVal.replace(re2, '$1$2$4.');
}
newVal = newVal.replace(/\.$/, ''); 
return newVal;
}
function moveDecimalNF(val, left, places)
{
var newVal = '';
if (places == null) {
newVal = this.moveDecimalAsString(val, left);
} else {
newVal = this.moveDecimalAsString(val, left, places);
}
return parseFloat(newVal);
}
function getRoundedNF(val)
{
val = this.moveDecimalRight(val);
if (this.truncate) {
val = val >= 0 ? Math.floor(val) : Math.ceil(val); 
} else {
val = Math.round(val);
}
val = this.moveDecimalLeft(val);
return val;
}
function preserveZerosNF(val)
{
var i;
val = this.expandExponential(val);
if (this.places <= 0) return val; 
var decimalPos = val.indexOf('.');
if (decimalPos == -1) {
val += '.';
for (i=0; i<this.places; i++) {
val += '0';
}
} else {
var actualDecimals = (val.length - 1) - decimalPos;
var difference = this.places - actualDecimals;
for (i=0; i<difference; i++) {
val += '0';
}
}
return val;
}
function justNumberNF(val)
{
newVal = val + '';
var isPercentage = false;
if (newVal.indexOf('%') != -1) {
newVal = newVal.replace(/\%/g, '');
isPercentage = true;
}
var re = new RegExp('[^\\' + this.inputDecimalValue + '\\d\\-\\+\\(\\)eE]', 'g');
newVal = newVal.replace(re, '');
var tempRe = new RegExp('[' + this.inputDecimalValue + ']', 'g');
var treArray = tempRe.exec(newVal); 
if (treArray != null) {
var tempRight = newVal.substring(treArray.index + treArray[0].length); 
newVal = newVal.substring(0,treArray.index) + this.PERIOD + tempRight.replace(tempRe, ''); 
}
if (newVal.charAt(newVal.length - 1) == this.DASH ) {
newVal = newVal.substring(0, newVal.length - 1);
newVal = '-' + newVal;
}
else if (newVal.charAt(0) == this.LEFT_PAREN
&& newVal.charAt(newVal.length - 1) == this.RIGHT_PAREN) {
newVal = newVal.substring(1, newVal.length - 1);
newVal = '-' + newVal;
}
newVal = parseFloat(newVal);
if (!isFinite(newVal)) {
newVal = 0;
//CID 0401 //2009.09.15 //Begin
this.isValid = false;
//CID 0401 //2009.09.15 //End
}else{
//CID 0401 //2009.09.15 //Begin
this.isValid = true;
//CID 0401 //2009.09.15 //End
}
if (isPercentage) {
newVal = this.moveDecimalLeft(newVal, 2);
}
return newVal;
}

/*===================================================================
 Author: Matt Kruse
 
 View documentation, examples, and source code at:
     http://www.JavascriptToolbox.com/

 NOTICE: You may use this code for any purpose, commercial or
 private, without any further permission from the author. You may
 remove this notice from your final code if you wish, however it is
 appreciated by the author if at least the web site address is kept.

 This code may NOT be distributed for download from script sites, 
 open source CDs or sites, or any other distribution method. If you
 wish you share this code with others, please direct them to the 
 web site above.
 
 Pleae do not link directly to the .js files on the server above. Copy
 the files to your own server for use with your site or webapp.
 ===================================================================*/
/*
Date functions

These functions are used to parse, format, and manipulate Date objects.
See documentation and examples at http://www.JavascriptToolbox.com/lib/date/

*/
Date.$VERSION = 1.02;

// Utility function to append a 0 to single-digit numbers
Date.LZ = function(x) {return(x<0||x>9?"":"0")+x};
// Full month names. Change this for local month names
Date.monthNames = new Array('January','February','March','April','May','June','July','August','September','October','November','December');
// Month abbreviations. Change this for local month names
Date.monthAbbreviations = new Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
// Full day names. Change this for local month names
Date.dayNames = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
// Day abbreviations. Change this for local month names
Date.dayAbbreviations = new Array('Sun','Mon','Tue','Wed','Thu','Fri','Sat');
// Used for parsing ambiguous dates like 1/2/2000 - default to preferring 'American' format meaning Jan 2.
// Set to false to prefer 'European' format meaning Feb 1
Date.preferAmericanFormat = true;

// If the getFullYear() method is not defined, create it
if (!Date.prototype.getFullYear) { 
	Date.prototype.getFullYear = function() { var yy=this.getYear(); return (yy<1900?yy+1900:yy); } 
} 

// Parse a string and convert it to a Date object.
// If no format is passed, try a list of common formats.
// If string cannot be parsed, return null.
// Avoids regular expressions to be more portable.
Date.parseString = function(val, format) {
	// If no format is specified, try a few common formats
	if (typeof(format)=="undefined" || format==null || format=="") {
		var generalFormats=new Array('y-M-d','MMM d, y','MMM d,y','y-MMM-d','d-MMM-y','MMM d','MMM-d','d-MMM');
		var monthFirst=new Array('M/d/y','M-d-y','M.d.y','M/d','M-d');
		var dateFirst =new Array('d/M/y','d-M-y','d.M.y','d/M','d-M');
		var checkList=new Array(generalFormats,Date.preferAmericanFormat?monthFirst:dateFirst,Date.preferAmericanFormat?dateFirst:monthFirst);
		for (var i=0; i<checkList.length; i++) {
			var l=checkList[i];
			for (var j=0; j<l.length; j++) {
				var d=Date.parseString(val,l[j]);
				if (d!=null) { 
					return d; 
				}
			}
		}
		return null;
	}

	this.isInteger = function(val) {
		for (var i=0; i < val.length; i++) {
			if ("1234567890".indexOf(val.charAt(i))==-1) { 
				return false; 
			}
		}
		return true;
	};
	this.getInt = function(str,i,minlength,maxlength) {
		for (var x=maxlength; x>=minlength; x--) {
			var token=str.substring(i,i+x);
			if (token.length < minlength) { 
				return null; 
			}
			if (this.isInteger(token)) { 
				return token; 
			}
		}
	return null;
	};
	val=val+"";
	format=format+"";
	var i_val=0;
	var i_format=0;
	var c="";
	var token="";
	var token2="";
	var x,y;
	var year=new Date().getFullYear();
	var month=1;
	var date=1;
	var hh=0;
	var mm=0;
	var ss=0;
	var ampm="";
	while (i_format < format.length) {
		// Get next token from format string
		c=format.charAt(i_format);
		token="";
		while ((format.charAt(i_format)==c) && (i_format < format.length)) {
			token += format.charAt(i_format++);
		}
		// Extract contents of value based on format token
		if (token=="yyyy" || token=="yy" || token=="y") {
			if (token=="yyyy") { 
				x=4;y=4; 
			}
			if (token=="yy") { 
				x=2;y=2; 
			}
			if (token=="y") { 
				x=2;y=4; 
			}
			year=this.getInt(val,i_val,x,y);
			if (year==null) { 
				return null; 
			}
			i_val += year.length;
			if (year.length==2) {
				if (year > 70) { 
					year=1900+(year-0); 
				}
				else { 
					year=2000+(year-0); 
				}
			}
		}
		else if (token=="MMM" || token=="NNN"){
			month=0;
			var names = (token=="MMM"?(Date.monthNames.concat(Date.monthAbbreviations)):Date.monthAbbreviations);
			for (var i=0; i<names.length; i++) {
				var month_name=names[i];
				if (val.substring(i_val,i_val+month_name.length).toLowerCase()==month_name.toLowerCase()) {
					month=(i%12)+1;
					i_val += month_name.length;
					break;
				}
			}
			if ((month < 1)||(month>12)){
				return null;
			}
		}
		else if (token=="EE"||token=="E"){
			var names = (token=="EE"?Date.dayNames:Date.dayAbbreviations);
			for (var i=0; i<names.length; i++) {
				var day_name=names[i];
				if (val.substring(i_val,i_val+day_name.length).toLowerCase()==day_name.toLowerCase()) {
					i_val += day_name.length;
					break;
				}
			}
		}
		else if (token=="MM"||token=="M") {
			month=this.getInt(val,i_val,token.length,2);
			if(month==null||(month<1)||(month>12)){
				return null;
			}
			i_val+=month.length;
		}
		else if (token=="dd"||token=="d") {
			date=this.getInt(val,i_val,token.length,2);
			if(date==null||(date<1)||(date>31)){
				return null;
			}
			i_val+=date.length;
		}
		else if (token=="hh"||token=="h") {
			hh=this.getInt(val,i_val,token.length,2);
			if(hh==null||(hh<1)||(hh>12)){
				return null;
			}
			i_val+=hh.length;
		}
		else if (token=="HH"||token=="H") {
			hh=this.getInt(val,i_val,token.length,2);
			if(hh==null||(hh<0)||(hh>23)){
				return null;
			}
			i_val+=hh.length;
		}
		else if (token=="KK"||token=="K") {
			hh=this.getInt(val,i_val,token.length,2);
			if(hh==null||(hh<0)||(hh>11)){
				return null;
			}
			i_val+=hh.length;
			hh++;
		}
		else if (token=="kk"||token=="k") {
			hh=this.getInt(val,i_val,token.length,2);
			if(hh==null||(hh<1)||(hh>24)){
				return null;
			}
			i_val+=hh.length;
			hh--;
		}
		else if (token=="mm"||token=="m") {
			mm=this.getInt(val,i_val,token.length,2);
			if(mm==null||(mm<0)||(mm>59)){
				return null;
			}
			i_val+=mm.length;
		}
		else if (token=="ss"||token=="s") {
			ss=this.getInt(val,i_val,token.length,2);
			if(ss==null||(ss<0)||(ss>59)){
				return null;
			}
			i_val+=ss.length;
		}
		else if (token=="a") {
			if (val.substring(i_val,i_val+2).toLowerCase()=="am") {
				ampm="AM";
			}
			else if (val.substring(i_val,i_val+2).toLowerCase()=="pm") {
				ampm="PM";
			}
			else {
				return null;
			}
			i_val+=2;
		}
		else {
			if (val.substring(i_val,i_val+token.length)!=token) {
				return null;
			}
			else {
				i_val+=token.length;
			}
		}
	}
	// If there are any trailing characters left in the value, it doesn't match
	if (i_val != val.length) { 
		return null; 
	}
	// Is date valid for month?
	if (month==2) {
		// Check for leap year
		if ( ( (year%4==0)&&(year%100 != 0) ) || (year%400==0) ) { // leap year
			if (date > 29){ 
				return null; 
			}
		}
		else { 
			if (date > 28) { 
				return null; 
			} 
		}
	}
	if ((month==4)||(month==6)||(month==9)||(month==11)) {
		if (date > 30) { 
			return null; 
		}
	}
	// Correct hours value
	if (hh<12 && ampm=="PM") {
		hh=hh-0+12; 
	}
	else if (hh>11 && ampm=="AM") { 
		hh-=12; 
	}
	return new Date(year,month-1,date,hh,mm,ss);
}

// Check if a date string is valid
Date.isValid = function(val,format) {
	return (Date.parseString(val,format) != null);
}

// Check if a date object is before another date object
Date.prototype.isBefore = function(date2) {
	if (date2==null) { 
		return false; 
	}
	return (this.getTime()<date2.getTime());
}

// Check if a date object is after another date object
Date.prototype.isAfter = function(date2) {
	if (date2==null) { 
		return false; 
	}
	return (this.getTime()>date2.getTime());
}

// Check if two date objects have equal dates and times
Date.prototype.equals = function(date2) {
	if (date2==null) { 
		return false; 
	}
	return (this.getTime()==date2.getTime());
}

// Check if two date objects have equal dates, disregarding times
Date.prototype.equalsIgnoreTime = function(date2) {
	if (date2==null) { 
		return false; 
	}
	var d1 = new Date(this.getTime()).clearTime();
	var d2 = new Date(date2.getTime()).clearTime();
	return (d1.getTime()==d2.getTime());
}

// Format a date into a string using a given format string
Date.prototype.format = function(format) {
	format=format+"";
	var result="";
	var i_format=0;
	var c="";
	var token="";
	var y=this.getYear()+"";
	var M=this.getMonth()+1;
	var d=this.getDate();
	var E=this.getDay();
	var H=this.getHours();
	var m=this.getMinutes();
	var s=this.getSeconds();
	var yyyy,yy,MMM,MM,dd,hh,h,mm,ss,ampm,HH,H,KK,K,kk,k;
	// Convert real date parts into formatted versions
	var value=new Object();
	if (y.length < 4) {
		y=""+(+y+1900);
	}
	value["y"]=""+y;
	value["yyyy"]=y;
	value["yy"]=y.substring(2,4);
	value["M"]=M;
	value["MM"]=Date.LZ(M);
	value["MMM"]=Date.monthNames[M-1];
	value["NNN"]=Date.monthAbbreviations[M-1];
	value["d"]=d;
	value["dd"]=Date.LZ(d);
	value["E"]=Date.dayAbbreviations[E];
	value["EE"]=Date.dayNames[E];
	value["H"]=H;
	value["HH"]=Date.LZ(H);
	if (H==0){
		value["h"]=12;
	}
	else if (H>12){
		value["h"]=H-12;
	}
	else {
		value["h"]=H;
	}
	value["hh"]=Date.LZ(value["h"]);
	value["K"]=value["h"]-1;
	value["k"]=value["H"]+1;
	value["KK"]=Date.LZ(value["K"]);
	value["kk"]=Date.LZ(value["k"]);
	if (H > 11) { 
		value["a"]="PM"; 
	}
	else { 
		value["a"]="AM"; 
	}
	value["m"]=m;
	value["mm"]=Date.LZ(m);
	value["s"]=s;
	value["ss"]=Date.LZ(s);
	while (i_format < format.length) {
		c=format.charAt(i_format);
		token="";
		while ((format.charAt(i_format)==c) && (i_format < format.length)) {
			token += format.charAt(i_format++);
		}
		if (typeof(value[token])!="undefined") { 
			result=result + value[token]; 
		}
		else { 
			result=result + token; 
		}
	}
	return result;
}

// Get the full name of the day for a date
Date.prototype.getDayName = function() { 
	return Date.dayNames[this.getDay()];
}

// Get the abbreviation of the day for a date
Date.prototype.getDayAbbreviation = function() { 
	return Date.dayAbbreviations[this.getDay()];
}

// Get the full name of the month for a date
Date.prototype.getMonthName = function() {
	return Date.monthNames[this.getMonth()];
}

// Get the abbreviation of the month for a date
Date.prototype.getMonthAbbreviation = function() { 
	return Date.monthAbbreviations[this.getMonth()];
}

// Clear all time information in a date object
Date.prototype.clearTime = function() {
  this.setHours(0); 
  this.setMinutes(0);
  this.setSeconds(0); 
  this.setMilliseconds(0);
  return this;
}

// Add an amount of time to a date. Negative numbers can be passed to subtract time.
Date.prototype.add = function(interval, number) {
	if (typeof(interval)=="undefined" || interval==null || typeof(number)=="undefined" || number==null) { 
		return this; 
	}
	number = +number;
	if (interval=='y') { // year
		this.setFullYear(this.getFullYear()+number);
	}
	else if (interval=='M') { // Month
		this.setMonth(this.getMonth()+number);
	}
	else if (interval=='d') { // Day
		this.setDate(this.getDate()+number);
	}
	else if (interval=='w') { // Weekday
		var step = (number>0)?1:-1;
		while (number!=0) {
			this.add('d',step);
			while(this.getDay()==0 || this.getDay()==6) { 
				this.add('d',step);
			}
			number -= step;
		}
	}
	else if (interval=='h') { // Hour
		this.setHours(this.getHours() + number);
	}
	else if (interval=='m') { // Minute
		this.setMinutes(this.getMinutes() + number);
	}
	else if (interval=='s') { // Second
		this.setSeconds(this.getSeconds() + number);
	}
	return this;
}

//====================================================================

//CID 0445 //2009.11.10 //Begin
function InfoJet_IsFireFox() {
    if (navigator.userAgent.indexOf("Firefox") > 0) {
        return true;
    } else {
        return false;
    }
}
//CID 0445 //2009.11.10 //End

//CID 0017 //2008.06.16 //Begin
function InfoJet_InsertAdjacentHTMLBeforeEnd( targetNode, html ){
	if( InfoJet_IsIE() ){
		targetNode.insertAdjacentHTML( "BeforeEnd", html );
	}else if( InfoJet_IsFireFox() ){
		var range = document.createRange();
		var parsedNode = range.createContextualFragment( html );
		targetNode.appendChild( parsedNode );
	}else{
		//CID 0445 //2009.11.10 //Begin
		var range = targetNode.ownerDocument.createRange();
        range.selectNodeContents(targetNode);
        range.collapse(targetNode);
        var df = range.createContextualFragment(html);
        targetNode.appendChild(df);
        //CID 0445 //2009.11.10 //End
	}
}
//CID 0017 //2008.06.14 //End

//CID 0785 //2011.02.23 //Begin
function InfoJet_ReplaceNodeWithHTML(targetNode, html) {
    if (InfoJet_IsIE()) {
        targetNode.outerHTML = html;
    } else {
        //Not work in Chrome.
        var range = document.createRange();
        var parsedNode = range.createContextualFragment(html);
        targetNode.parentNode.replaceChild(parsedNode, targetNode);
    }
}
//CID 0785 //2011.02.23 //End

//CID 0020 //2008.06.20 //Begin
function InfoJet_RemoveHtmlElement( element ){
	if( InfoJet_IsIE() ){
		element.outerHTML = "";
	}else{
		element.parentNode.removeChild( element );
	}
}
//CID 0020 //2008.06.20 //End

//CID 0255 //2009.05.19 //Begin
function InfoJet_GetPreviousElement( source ){
	var previousSibling = source.previousSibling;
	while( previousSibling != null ){
		if( previousSibling.tagName && previousSibling.tagName.indexOf( "/" ) < 0 ){
			return previousSibling;
		}else{
			previousSibling = previousSibling.previousSibling;
		}
	}
	return null;
}
//CID 0255 //2009.05.19 //End

//CID 0255 //2009.05.19 //Begin
function InfoJet_GetNextElement( source ){
	var nextSibling = source.nextSibling;
	while( nextSibling != null ){
		if( nextSibling.tagName && nextSibling.tagName.indexOf( "/" ) < 0 ){
			return nextSibling;
		}else{
			nextSibling = nextSibling.nextSibling;
		}
	}
	return null;
}
//CID 0255 //2009.05.19 //End

//CID 0828 //2011.03.10 //Begin
function InfoJet_GetElements(element) {
    var elements = new Array();
    for (var i = 0; i < element.childNodes.length; i++) {
        var childNode = element.childNodes[i];
        if (childNode.nodeType == 1 && childNode.tagName && childNode.tagName.indexOf("/") < 0) {
            elements.push(childNode);
        }
    }
    return elements;
}
//CID 0828 //2011.03.10 //End

//CID 0293 //2009.05.28 //Begin
function InfoJet_GetFirstChild( source ){
	for( var i = 0; i < source.childNodes.length; i ++ ){
		var child = source.childNodes[i];
		if( child.tagName && child.tagName.indexOf( "/" ) < 0 ){
			return child;
		}
	}
}
//CID 0293 //2009.05.28 //End

//CID 0293 //2009.05.28 //Begin
function InfoJet_GetLastChild( source ){
	var lastChild = null;
	for( var i = 0; i < source.childNodes.length; i ++ ){
		var child = source.childNodes[i];
		if( child.tagName && child.tagName.indexOf( "/" ) < 0 ){
			lastChild = child;
		}
	}
	return lastChild;
}
//CID 0293 //2009.05.28 //End

//CID 0306 //2009.06.18 //Begin
function InfoJet_CancelEvent( event ){
	if( InfoJet_IsIE() ){
		event.cancelBubble = true;
	}else{
		event.stopPropagation();
	}
}
//CID 0306 //2009.06.18 //End

//CID 0382 //2009.09.22 //Begin
function InfoJet_GetHtmlSelectValue( control ){
	if( InfoJet_IsIE() ){
		return control.value;
	}else{
		try{
			var selectedOption = control.options[ control.selectedIndex ];
			if( selectedOption.getAttribute( "value" ) != null ){
				return control.value;
			}else{
				return "";
			}
		}catch(e){
			return control.value;
		}
	}
}
//CID 0382 //2009.09.22 //End

//CID 0380 //2009.09.22 //Begin
function InfoJet_RemoveFocus(){
	if( InfoJet_IsIE() ){
		document.body.focus();
    } else {
        //CID 1125 //2012.03.06 //Begin
        if (InfoJet_FocusHolder != null) {
            InfoJet_FocusHolder.focus();
        }
        //CID 1125 //2012.03.06 //End
	}
}
//CID 0380 //2009.09.22 //End

//CID 0629 //2010.08.03 //Begin
function InfoJet_EndsWith(str1, str2) {
    //CID 0774 //2011.01.27 //Begin
    if (str1.length < str2.length) {
        return false;
    }
    //CID 0774 //2011.01.27 //End
    if( str1.indexOf(str2) == (str1.length - str2.length) ){
        return true;   
    }else{
        return false;
    }
}
//CID 0629 //2010.08.03 //End

//CID 0638 //2010.08.08 //Begin
function InfoJet_Trim(str) {
    return str.replace(/(^\s*)|(\s*$)/g, "");
}
//CID 0638 //2010.08.08 //End

//CID 1382 //2012.10.09 //Begin
function InfoJet_GetText(source) {
    if (InfoJet_IsIE()) {
        return source.innerHTML;
    } else {
        if (source.textContent) {
            return source.textContent;
        } else {
            return "";
        }
    }
}
//CID 1382 //2012.10.09 //End

//CID 0629 //2010.08.03 //Begin
function InfoJet_UpdateSingleFieldByName(name, newValue) {
    var form = document.getElementById("xdoc_form");
    for (var i = 0; i < form.childNodes.length; i++) {
        var field = form.childNodes[i];
        if (field.nodeType == 1) {
            if (field.name) {
                if (InfoJet_EndsWith(field.name, name)) {
                    field.value = newValue;
                    var uiFieldId = field.name.substring( 4 );
                    var uiField = document.getElementById(uiFieldId);
                    if( uiField != null ){
                        uiField.value = newValue;
                    }
                    for (var index = 1; true; index++) {
                        uiField = document.getElementById(uiFieldId + "," + index);
                        if (uiField != null) {
                            uiField.value = newValue;
                        } else {
                            break;
                        }
                    }
                    break;
                }
            }
        }
    }
}
//CID 0629 //2010.08.03 //End

//CID 0629 //2010.08.03 //Begin
function InfoJet_GetSingleFieldValueByName(name) {
    var form = document.getElementById("xdoc_form");
    for (var i = 0; i < form.childNodes.length; i++) {
        var field = form.childNodes[i];
        if (field.nodeType == 1) {
            if (field.name) {
                if (InfoJet_EndsWith(field.name, name)) {
                    return field.value;
                }
            }
        }
    }
    return null;
}
//CID 0629 //2010.08.03 //End

//CID 0877 //2011.04.21 //Begin
function InfoJet_StopEvent(pE) {
    if (!pE) {
        if (window.event) {
            pE = window.event;
        }
    } else {
        return;
    }
    if (pE.cancelBubble != null) {
        pE.cancelBubble = true;
    }
    if (pE.stopPropagation) {
        pE.stopPropagation();
    }
    if (pE.preventDefault) {
        pE.preventDefault();
    }
    if (window.event) {
        pE.returnValue = false;
    }
    if (pE.cancel != null) {
        pE.cancel = true;
    }
}
//CID 0877 //2011.04.21 //End